我想选择装有照片和电话实体的员工。 我正在使用这样的查询:
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();
Photo和HomeTelephone属性的结果为空,但PhotoId和HomeTelephone设置为......
我做错了什么?
答案 0 :(得分:2)
也许这可以解决你的问题。
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();