【发布时间】:2018-04-06 11:15:49
【问题描述】:
我有两个实体
类别
public class Category
{
public int Id {get; set;}
public int? ParentId {get; set;}
public string Name {get; set;}
public virtual ICollection<Document> Documents {get; set;}
}
文档
public class Document
{
public int Id {get; set;}
public int CategoryId {get; set;}
public string Name {get; set;}
public virtual Category Category {get; set;}
}
如何按 categoryId 获取所有子类别的总文档?
示例
类别
Id ParentId Name
1 null One
2 null Two
3 1 One Live 1
4 3 One Live 2
文件
Id CategoryId Name
1 1 Document 1
2 2 Document 5
3 3 Document 2
4 4 Document 3
我想要获得全部文档一个。我应该得到 3 的总数
【问题讨论】:
-
至少尝试一下,我们可以帮助你
-
对不起,我更新了我的问题
标签: c# linq entity-framework-6