Last post Sep 02, 2016 08:37 AM by Cathy Zou
Sep 01, 2016 09:46 AM|sudip_inn|LINK
please see the query and tell me on which table the where will be used ? does it used for Teams table or
Owner table or
Members tables ?
var query = context.Teams.Include(x => x.Owner).Include(x => x.Members).Where( ... );
if we need to restrict data in Owner table or
tables then where to add the where clause.......give me a sample code to explain it. thanks
Sep 01, 2016 10:17 AM|Mukesh_Kumar|LINK
EF multiple includes and where
If you are using include statement and using where clause then where clause will work as per all include if have.
var query = context.Teams.Include(x => x.Owner).Include(x => x.Members).Where( This where will work on Members table );
var query = context.Teams.Where( This where will work on Teams table ).Include(x => x.Owner).Include(x => x.Members).Where( This where will work on Members table );
Hope this will help you.
Sep 01, 2016 11:06 AM|sudip_inn|LINK
if i need to apply where for Teams and Owner table then where to add the where clause. provide one sample code. thanks
Sep 02, 2016 08:37 AM|Cathy Zou|LINK
From your description, I suggest you could use linq, the following code is an example, you could refer to it.
//blogs equal to Teams class, Posts equal to Owner
var query = from c in context.Blogs.Where(w => w.BlogId == 2).Include(i => i.Posts.Where(w => w.PostId == 3)) select c;
Hope this can help you. If you have any question and confusion about the problem. Please don't hesitate to let me know.