Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.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
C# 实体框架4包括+;表联接不能一起工作_C#_Entity Framework_Linq To Entities - Fatal编程技术网

C# 实体框架4包括+;表联接不能一起工作

C# 实体框架4包括+;表联接不能一起工作,c#,entity-framework,linq-to-entities,C#,Entity Framework,Linq To Entities,我想选择已加载照片和电话实体的员工。 我使用这样的查询: var empl = from user in ObjectContext.Users from employee in ObjectContext.Employees.Include("Photo").Include("HomeTelephone") where use

我想选择已加载照片和电话实体的员工。 我使用这样的查询:

var empl = from user in ObjectContext.Users
                           from employee in ObjectContext.Employees.Include("Photo").Include("HomeTelephone")
                           where
                               user.Id == userId &&
                               employee.Id == user.EmployeeId &&
                               employee.Deleted == false &&
                               employee.OwnerOrganizationId == Singleton.OrganizationId
                           select employee;

var result = empl.FirstOrDefault();
结果具有照片和家庭电话属性的空值,但具有照片ID和家庭电话集


我做错了什么?

也许这能解决你的问题

User user;

using (var ctx = new Model1Container())
{

    user = ctx.UserSet
               .Include("Employee")
               .Include("Employee.Photo")
               .Include("Employee.Telefon")
               .Single(x => x.Id == id);  
}
Console.Out.WriteLine(user.UserName);
Console.Out.WriteLine(user.Employee.Telefon.First().Number);
Console.ReadLine();