我有3张如下图所示的表格
我在c#(自动生成)
上有实体框架codefirst模型我正在尝试从包含每个元素的附件列表的实体中获取IEnumerable,并且我希望每个附件中包含AttachmentType的附件元素。
我需要更好的演示:
public IEnumerable<Registry> GetTableData()
{
IQueryable<Registry> _registries = _entities.Registry;
IEnumerable<Registry> data;
data = _registries
.Where(p=>p.IsDeleted==false)
.Include(p=>p.Attachments.Where(x=>x.IsDeleted==false))
.AsEnumerable();//this query should have change because I cant get Attachmenttypes from this
return data;
}
与GetTableData()方法类似
SELECT DISTINCT ?subjectPrefLabel ?a ?b ?o
WHERE
{
?subject skosxl:prefLabel/skosxl:literalForm ?subjectPrefLabel .
?subject skos:broader/skos:broader/skos:broader/skosxl:prefLabel/skosxl:literalForm ?a
FILTER regex(?subjectPrefLabel, "Dreamworks", 'i')
}
ORDER BY ?subjectPrefLabel
谢谢大家,感谢您的帮助。
答案 0 :(得分:0)
您还必须在查询中添加额外的AttachmentType Include。
public IEnumerable<Registry> GetTableData()
{
IQueryable<Registry> _registries = _entities.Registry;
IEnumerable<Registry> data = _registries
.Include(x => x.Attachments)
.Include("Attachments.AttachmentType")
// here do necessary filtering with Where()
// ...
return data;
}
答案 1 :(得分:0)
使用此功能
public IEnumerable<Registry> GetTableData()
{
IQueryable<Registry> _registries = _entities.Registry,where(m=>m.IsDeleted==false);
IEnumerable<Registry> data;
data = _registries .Include(p=>p.Attachments.Where(x=>x.IsDeleted==false)).
include(p=>p.AttachmentType).AsEnumerable();
return data;
}