Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Using jQGrid with DbContext (Code First techinques)
01/02/2012
18:03
Avatar
pcapozzi
USA
Member
Members
Forum Posts: 3
Member Since:
01/02/2012
sp_UserOfflineSmall Offline

Hi,

I am working with the jQGrid with MVC3 using code first techniques.  This dictates the use of the DBContext object for the data layer.  I am having trouble gettingthe DBContext to work with ObjectQuery. So in your sample code 'jqGridDemo'  there is a line :

 ObjectQuery<Question> filteredQuery = (f == null ? context.Questions : f.FilterObjectSet (context.Questions));

I need to use DBContext in place of context.Questions.  If I try :

 IQueryable<Job> filteredQuery = (f == null ? dbcontext.Jobs : f.FilterObjectSet(dbcontext.Jobs));

then I get an error message:

"The type arguments for method 'TempRxMVC.Controllers.Filters.FilterObjectSet<T>(System.Data.Objects.ObjectQuery<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly." and also the line :

var queryDetails = (from item in pagedQuery select new { item.Id, item.Votes, item.Title }).ToList();

gives me a error:

"No overload for method 'Skip' takes 3 arguments"

Is there a way to use DBContext instead of ObjectContext with the grid?

Thanks for your help!

PatC

10/02/2012
00:59
Avatar
pcapozzi
USA
Member
Members
Forum Posts: 3
Member Since:
01/02/2012
sp_UserOfflineSmall Offline

To get jQgrid to work with the DBContext object you next to build a method that exposes an ObjectSet from the dbContext objext.

eg.

  <Job> Jobset {

ObjectSet

   get {

   ObjectContext ctx = ((IObjectContextAdapter)db).ObjectContext;

   return _Jobset ?? (_Jobset = ctx.CreateObjectSet<Job>("Jobs"));

    }

}

private

 

You then can use this objectSet in  the jQgrid code

 

ObjectQuery



<Job> filteredQuery = (f == null ? Jobset : f.FilterObjectSet(Jobset));

 

ObjectSet<Job> _Jobset;

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
63 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information