vb.net - How to write this LINQ/EF query? -
so have entity framework 5 model includes many-to-many relationship.
categoryvalues --< coursecategoryvalues >-- courses
i have linq query selects every course
in database. modify select courses
belong specific categoryvalue
. attempt far has failed?
can me figure out?
this have tried:
using database sitedatacontext = new sitedatacontext database.configuration.proxycreationenabled = false database.courses.include("classes") database.courses.include("coursecategoryvalues") query = (from c in database.courses select c order c.name).where( function(c) 0 < c.classes.where(function([class]) [class].status.tolower = "open").count ).include(function(r) r.classes).include(function(r) r.coursecategoryvalues) ' here trying narrow down query results if (pid.hasvalue) andalso (0 <> pid.value) query.where(function(c) c.coursecategoryvalues.any(function(v) v.categoryvalue.categoryvalueid = pid)) end if model.pagedata = query.tolist end using
i think missing assignment of filter query variable. where
returns new queryable, doesn't modify queryable apply where
to. so, need:
query = query.where(...)
the where
expression looks correct me.
Comments
Post a Comment