Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linq RIA服务过滤掉包含的实体_Linq_Entity Framework_Silverlight_Wcf Ria Services_Ria - Fatal编程技术网

Linq RIA服务过滤掉包含的实体

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

下面返回一栋楼里的所有人和他们的所有计算机,这是可行的

我想将其更改为仅包括Active==1的计算机,以及ActivityTypeId==5的ActivityLogs。但如果他们两个都没有,我还是希望那个人回来

  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服务中得到这些信息?我建议你开始一个新的问题,因为你原来的问题并没有真正提出这个问题,也没有包括任何关于你的设置和你想要完成的事情的细节。