I use c#, linq and EF4.
I have two tables in my DataBase represented in my Conceptual Model:
DataBase Tables:
CmsContents
CmsCategories
CmsRelatedCategories (Pure Juction Table)
Entity Type:
CmsContent
CmsCategory
Entyt Set:
CmsContents
CmsCategories
I have some Navigational Properties:
for CmsContents --> CmsCategories --> Return Collection of Cms CmsCategory
for CmsCategories --> CmsContents --> Return Collection of Cms CmsContents
I need query Entity Framework to retrive a list of Categories for a selected Content not associated in the Junction table.
At the moment I use this code (note the two FROM):
var categories = from category in context.CmsCategories
from content in category.CmsContents
select category;
That Returns a list of all category not associated in the entire database and not to a specific Content.
I need show the list of Categories not associates with a SPECIFIC Content
- Any idea how to do it?
- May I do it with JOIN? (EF does not map directly he Pure Junction Table)
Could you please write me the LINQ query so I can have a clear picture.
Thanks fro your help.
You could try:
myContent is an instance of CmsContent, assuming you retrieved it before and you have lazy loading enabled.
Edit: a possible sample of code: