1
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;