C# NHibernate查询字典(map)的值

C# NHibernate查询字典(map)的值,c#,nhibernate,queryover,idictionary,C#,Nhibernate,Queryover,Idictionary,对于我正在进行的项目,我需要查询Nhibernate中映射字典的值。差不多 SELECT * FROM EntityWithDictionary WHERE EntityWithDictionary in (select EntityFromDictionaryId FROM Dictionary where value = 'testvalue') 我试过几件事,但我不知道怎么做。这是我的 实体 在这个查询中,NHibernate选择使用2个别名(dictionary1,dicti

对于我正在进行的项目,我需要查询Nhibernate中映射字典的值。差不多

SELECT * FROM EntityWithDictionary WHERE EntityWithDictionary 
    in (select EntityFromDictionaryId FROM Dictionary where value = 'testvalue')
我试过几件事,但我不知道怎么做。这是我的

实体 在这个查询中,NHibernate选择使用2个别名(dictionary1,dictionary3),其中只创建了1个别名(dictionary3)

伊克里特里亚
如果Linq是一个选项,请使用

session.Query<EntityWithDictionary>()
    .Where(f => f.Dictionary["key"] == "value")
    .ToList();
session.Query()
.其中(f=>f.Dictionary[“key”]==“value”)
.ToList();

谢谢,但在这种情况下,linq不是一个选项。我觉得它像个bug。在这种情况下,除了修复它之外,我看不到使用hql/LINQ的真正替代方案
public EntityWithDictionaryMap()
{
    Id(s => s.Id);
    Map(s => s.Description);
    HasMany(m => m.Dictionary)
        .Table("`Dictionary`")
        .KeyColumn("EntityWithDictionaryId")
        .AsMap<string>("`Key`")
        .Element("`Value`")
        .LazyLoad()
        .Access.CamelCaseField(Prefix.Underscore)
        .Cascade.All();
}
EntityWithDictionary entityWithDictionary = null;
var result = session.QueryOver<EntityWithDictionary>(() =>entityWithDictionary)
        .JoinQueryOver(dictionary =>dictionary.Dictionary)
        .UnderlyingCriteria.Add(Restrictions.Eq("elements", "test")).List();
SELECT this_.Id as Id0_0_, this_.Description as Descript2_0_0_ FROM
[EntityWithDictionary] this_ inner join [Dictionary] dictionary3_ on
this_.Id=dictionary3_.EntityWithDictionaryId WHERE dictionary1_.[Value] = @p0 ]
ICriteria criteria = session.CreateCriteria<EntityWithDictionary>();
criteria("Dictionary").Add(Restrictions.Eq("elements", "testValue"));
var result = criteria.List();
from EntityWithDictionaryId e where 'aDictionaryValue' in elements(m.Dictionary).
session.Query<EntityWithDictionary>()
    .Where(f => f.Dictionary["key"] == "value")
    .ToList();