Silverlight DomainService not returning information from include()
I have two queries in my RIA DomainService. one is a simple get using linq and the other is a get with a peramiter and a linq join. the simple 开发者_运维百科get when using include() returns the data i want to my silverlight datagrid. the one with the join does not, why?
here are my two methods. the top one is the one that works.
public IQueryable<UserProfile> GetUserProfiles()
{
// GetUserProfiles order by sum of carma
return from up in ObjectContext.UserProfiles.Include("PriceRange")
where up.Active
orderby up.SumKarma descending
select up;
}
public IQueryable<UserProfile> GetUserProfilesByCountyID(int searchCountyID)
{
return from up in ObjectContext.UserProfiles.Include("PriceRange")
join upsc in ObjectContext.UserProfileSearchCounties on up.IDUserProfile equals upsc.IDUserProfile
where up.Active && upsc.IDSearchCounty == searchCountyID
orderby up.SumKarma descending
select up;
}
UPDATE: with comment from Cubicle.Jockey i was able to work through this. below is what i ended up using.
public IEnumerable<UserProfileSearchCounty> GetUserProfilesByCountyID(int searchCountyID)
{
return (from upsc in ObjectContext.UserProfileSearchCounties.Include("UserProfile").Include("UserProfile.PriceRange")
where upsc.UserProfile.Active && upsc.IDSearchCounty == searchCountyID
orderby upsc.UserProfile.SumKarma descending
select upsc).ToList();
}
All the data is not being returned because you are doing a select on up which is just UserProfile and not the joined query you were performing.
精彩评论