通过映射字典进行 NHibertate 查询
你能帮我解决 nhibernate 查询吗? 有下一个带有映射的对象:
public ObjectkState
{
public long Id {get;set;}
public IDictionary<string,string> Context {get;set;}
public string Name {get; set;}
}
对象映射
public ObjectStateMap(): ClassMappublic ObjectStateMap()
{
Id(x => x.Id).GeneratedBy.Identity();
Map(x => x.Name);
HasMany(x => x.Context).Table("ContextItems").KeyColumn("TaskId")
.Cascade.All()
.AsMap("ItemKey").Element("ItemValue", c => c.Type());
}
请帮助我进行如下查询:查找名称=“New”且上下文包含键“TaskId”和值“3”的所有对象状态。不幸的是,我没有找到任何如何查找映射的 IDictionary 的示例。
Could you help me with nhibernate query.
There is next object with mapping:
public ObjectkState
{
public long Id {get;set;}
public IDictionary<string,string> Context {get;set;}
public string Name {get; set;}
}
Object mapping
public ObjectStateMap(): ClassMappublic ObjectStateMap()
{
Id(x => x.Id).GeneratedBy.Identity();
Map(x => x.Name);
HasMany(x => x.Context).Table("ContextItems").KeyColumn("TaskId")
.Cascade.All()
.AsMap("ItemKey").Element("ItemValue", c => c.Type());
}
Please help me to make query like: Find all ObjectStates where Name = "New" and Context contains key "TaskId" and value "3". Гnfortunately I don't find any examples how to find against mapped IDictionary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够使用 Linq to NHibernate。您还可以使用 HQL。
也许是这样的:
我知道我缺少值限制,但这很容易添加。
不过,我很难在 QueryOver 中找到此功能。
You should be able to use Linq to NHibernate. You can also use HQL.
Perhaps something like this:
I know i'm missing the Value restriction, but that's easy enough to add in.
I am struggling to find this functionality in QueryOver though.