Linq RIA服务过滤掉包含的实体
下面返回一栋楼里的所有人和他们的所有计算机,这是可行的 我想将其更改为仅包括Active==1的计算机,以及ActivityTypeId==5的ActivityLogs。但如果他们两个都没有,我还是希望那个人回来Linq RIA服务过滤掉包含的实体,linq,entity-framework,silverlight,wcf-ria-services,ria,Linq,Entity Framework,Silverlight,Wcf Ria Services,Ria,下面返回一栋楼里的所有人和他们的所有计算机,这是可行的 我想将其更改为仅包括Active==1的计算机,以及ActivityTypeId==5的ActivityLogs。但如果他们两个都没有,我还是希望那个人回来 public IQueryable<Person> GetPeople(int BuildingId) { return this.ObjectContext.People .Include("Compu
public IQueryable<Person> GetPeople(int BuildingId)
{
return this.ObjectContext.People
.Include("Computers")
.Include("ActivityLog")
.Where(p => p.buildingId == BuildingId && !p.migrated)
.OrderBy(p => p.name);
}
public IQueryable GetPeople(int BuildingId)
{
返回this.ObjectContext.People
。包括(“电脑”)
.包括(“活动日志”)
.Where(p=>p.buildingId==buildingId&&!p.migrated)
.OrderBy(p=>p.name);
}
不幸的是,使用Include
语法无法做到这一点。或者,您可以单独选择每个实体,如下所示:
var queryWithAllData = this.ObjectContext
.People
.Select(p => new
{
Person = p,
Computers = p.Computers.Where(c => c.Active == 1),
ActivityLogs = p.ActivityLog.Where(a => a.ActivityTypeId == 5)
});
// Do what you need with the records now that you have all the data.
我如何从RIA服务中得到这些信息?我建议你开始一个新的问题,因为你原来的问题并没有真正提出这个问题,也没有包括任何关于你的设置和你想要完成的事情的细节。