我有以下课程
public class Project : IWorkflowDocument
{
public string Id { get; set; }
public Dictionary<Type, List<DenormalizedWorkflowReference<IWorkflowDocument>>> Parents { get; set; }
}
public class DenormalizedWorkflowReference<T> where T : IWorkflowDocument
{
public string Id { get; set; }
public string Name { get; set; }
public static implicit operator DenormalizedWorkflowReference<T>(T doc)
{
return new DenormalizedWorkflowReference<T>
{
Id = doc.Id,
Name = doc.Name
};
}
}
在 Db 中存储带有一些父母的项目后,它如下所示:
{
"Name": "TestProject",
"Parents": {
"InterGrowth.Framework.MES.DomainObjects.Company, InterGrowth.Framework.MES.DomainObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null": [
{
"Id": "companies/225",
"Name": "Test Corporation"
}
]
},
"Children": {
"InterGrowth.Framework.MES.DomainObjects.Order, InterGrowth.Framework.MES.DomainObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null": [
{
"Id": "orders/97",
"Name": "Order_0"
}
]
}
}
如果类型和 ID 已知,那么通过父属性获取项目的正确查询是什么?我尝试了以下尝试,但均未成功:
var result = session.Query<Project>().Select(s => s.Parents[typeof (Company)]).Where(y => y.Any(u => u.Id == Company.Id));
var result = from project in session.Query<Project>() where project.Parents[typeof(Company)].Any(t=> t.Id == Company.Id) select project;