I am having a very tough time with this one. I have a Navigation property called Attachment that is part of an entity called ContentChannel. ContentChannel is a many to one relationship with KioskType.
In my domain service extension class, I have the following query:
public IQueryable<ContentChannel> GetContentChannelFromKioskType( long kioskTypeID )
{
var returnSet = (from cc in ObjectContext.ContentChannels.Include( "Attachment" )
join pcc in ObjectContext.PublishedContentChannels on cc.ContentChannelID equals pcc.ContentChannelID
where pcc.KioskTypeID == kioskTypeID
select cc);
return returnSet;
}
And this works just fine for returning the list of ContentChannels. But the Attachment in each ContentChannel is null.
I have tried [Include]
on the attachment property in my ContentChannel metadata class, in conjuction with ContentChannels.Include("Attachment")
in the above query- no luck, Attachment is always null.
I dug more and then found something to explicitly load my child item:
ObjectContext.LoadProperty( returnSet, "Attachment" );
But this generates the following error:
Cannot explicitly load property for entities that are detached. Objects loaded using the NoTracking merge option are always detached.
Is it because I'm doing a join that things are wonky and the Include doesnt work? What do I need to do? These attachments need to get loaded when I get a ContentChannel!
Any thoughts?