This subject is driving me crazy ;-) I'm trying to make a simple query joining two tables
I have the following:
Repository Class Method
public IQueryable<ADPerson> FindAll(string UserId) { return (from p in db.ADPerson select p); }
In my controller:
var ADPersonList = from o in ADPersonDB.FindAll(GetUserId()) join c in MSDNTypeDB.FindAll(GetUserId()) on o.MsdnTypeId equals c.MsdnTypeId select new ADPerson() { AdPersonId = o.AdPersonId, SamAccountName = o.SamAccountName, Description = o.Description, DisplayName = o.DisplayName, UserPrincipalName = o.UserPrincipalName, Enabled = o.Enabled, LastUpdated = o.LastUpdated, OnlineAssetTag = o.OnlineAssetTag, MsdnTypeId = o.MsdnTypeId, MsdnSubscription = c.MsdnTypeDescription, };
I get an error message:
{"The specified LINQ expression contains references to queries that are associated with different contexts."}
I also tried adding to the repository class:
Repository Class Method
public IQueryable<ADPerson> FindAll(string UserId) { //return (from p in db.ADPerson // select p); var query = from o in db.ADPerson join c in db.MsdnTypes on o.MsdnTypeId equals c.MsdnTypeId select new ADPerson() { AdPersonId = o.AdPersonId, SamAccountName = o.SamAccountName, Description = o.Description, DisplayName = o.DisplayName, UserPrincipalName = o.UserPrincipalName, Enabled = o.Enabled, LastUpdated = o.LastUpdated, OnlineAssetTag = o.OnlineAssetTag, MsdnTypeId = o.MsdnTypeId, MsdnSubscription = c.MsdnTypeDescription, }; return query; }
Is it really that difficult to make a simple join between two tables and populate a variable in the Entity infrastructure
thanks
source share