Linq to EF, I am using asp.net 4, EF 4 and C #.
Here are two ways I came up with to request my data. Paths A and C work fine. B, however, it is necessary to implement an additional WHERE operator (like "where c.ModeContent ==" NA ").
My question is:
- As for this type of join (e.g., outer join), what is the best approach to performance?
- Could you show me some code to implement the optional WHERE statement in B?
- Any way to improve this code?
Thank you for your time!: -)
// A var queryContents = from c in context.CmsContents where c.ModeContent == "NA" && !(from o in context.CmsContentsAssignedToes select o.ContentId) .Contains(c.ContentId) select c; // B - I need to implent where c.ModeContent == "NA" var result01 = from c in context.CmsContents join d in context.CmsContentsAssignedToes on c.ContentId equals d.ContentId into g where !g.Any() select c; // C var result02 = context.CmsContents.Where(x => x.ModeContent == "NA").Where(item1 => context.CmsContentsAssignedToes.All(item2 => item1.ContentId != item2.ContentId));
source share