entity framework - Filtering a Linq / Odata query over a 1 to many navigation property -


the following query works fine expand on navigation property, schedules, has many 1 relationship associatedlisting property:

from la in listingassociations.expand("associatedlisting").expand("associatedlisting/schedules") la.listingid==60 select la 

in results, can see multiple schedule objects corresponding each associatedlisting object. good.

however, when try add filter on of schedules fields:

from la in listingassociations.expand("associatedlisting").expand("associatedlisting/schedules") la.listingid==60 && la.associatedlisting.schedules.startdate > datetime.today select la 

i error:

"'system.collections.objectmodel.collection' not contain definition 'startdate' , no extension method 'startdate' accepting first argument of type 'system.collections.objectmodel.collection' found...".

so guess problem startdate field of schedule class, , "schedules" navigation property collection of schedule objects, hence schedules.startdate doesn't make sense. there must way specify filter in many 1 situation. how?

any appreciated!

change where clause this:

where la.listingid==60     && la.associatedlisting.schedules.startdate > datetime.today 

to this:

where la.listingid==60     && la.associatedlisting.schedules.all(x => x.startdate > datetime.today) 

if want of schedules have start date greater today (instead of filtering ones of them do), change all any.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -