如果我使用连接,则Include()方法不再有效,例如:
from e in dc.Entities.Include("Properties")
join i in dc.Items on e.ID equals i.Member.ID
where (i.Collection.ID == collectionID)
select e
Run Code Online (Sandbox Code Playgroud)
e.Properties 没有加载
没有连接,Include()可以工作
背风处
我有以下查询linq到实体.问题是它似乎没有加载"标签"关系,即使我已经包含了它的东西.如果我不加入标签,它工作正常,但我需要这样做.
var items = from i in db.Items.Include("Tags")
from t in i.Tags
where t.Text == text
orderby i.CreatedDate descending
select i;
Run Code Online (Sandbox Code Playgroud)
有没有其他方式来询问此查询?也许拆分或什么?
我想Include从输入中动态添加s params[].我怎样才能做到这一点?
这是我的代码
IQueryable<Work> query = this.ObjectContext.Works
.Include("EmployeeSender.Person")
.Include("EmployeeReceiver.Person")
.Include("WorkCode")
.Include("WorkFlowStep.WorkFlowFormState")
.Include("WorkFlow")
.Include("WorkRoot.EmployeeSender.Person")
.Include("WorkParent");
Run Code Online (Sandbox Code Playgroud) 我正在执行以下 LINQ 查询,该查询有效但不返回导航属性 Person 填充,我得到null.
public IEnumerable<SharePeople> GetSharePeopeByCarId(int carId)
{
return from q in _context.Cars
join s in _context.Shares
on q.CarId equals s.Car.CarId
join p in _context.SharePeople.Include(p => p.Person)
on s.ShareId equals p.ShareId
where q.CarId == carId
select p;
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,因为当我使用常规扩展方法_context.SharePeople.Include(p => p.Person)时。