Eri*_* J. 3 linq-to-entities entity-framework ef-code-first
给出如下内容:
public class Parent
{
public int Id { get; set; }
public List<Child> Children { get; set; }
}
// There is no reference to the parent in the object model
public class Child
{
public int Id { get; set; }
public string MyProperty { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
是否有可能加载只有一个孩子符合特定条件,对于给定父ID,还没有加载父实体?
如果我理解正确的话,应该这样做; 它将您想要的条件放在父级和子级上,但只选择子级.
from parent in db.Parents
from child in parent.Children
where parent.Id = 4711 &&
child.MyProperty == "olle"
select child;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1142 次 |
最近记录: |