0

以下は、建物内のすべての人々とそのすべてのコンピューターを返します。これは機能します。

これを変更して、Active == 1 のコンピューターと ActivityTypeId == 5 の ActivityLog のみを含めるようにします。

  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);
         }
4

1 に答える 1

0

残念ながら、これは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.
于 2013-10-18T20:00:23.513 に答える