Forum



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
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;
Most Users Ever Online: 715
Currently Online:
52 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66