Linq 如何在NHibernate中查询动态属性?

Linq 如何在NHibernate中查询动态属性?,linq,nhibernate,dynamic,queryover,Linq,Nhibernate,Dynamic,Queryover,我有这个问题。 我有一门课是这样的: public class WfStep { private readonly IDictionary properties = new Hashtable(); public virtual Guid Id { get; private set; } public virtual string Name { get; set; } public virtual dynamic Properties { get { retur

我有这个问题。 我有一门课是这样的:

public class WfStep
{
    private readonly IDictionary properties = new Hashtable();

    public virtual Guid Id { get; private set; }
    public virtual string Name { get; set; }
    public virtual dynamic Properties { get { return new HashtableDynamicObject(properties); } }
<class name="ConsoleApplication4.WfStep" table="WFSteps">

<id name="Id">
  <generator class="guid"/>
</id>
<property name="Name" />

<map name="Properties" table="WFSteps_Properties" access="field.lowercase">
  <key column="StepId" />
  <index column="PropertyName" type="System.String"/>
  <composite-element class="ConsoleApplication4.ValueItem, ConsoleApplication4">
    <property name="Value" type="System.String"/>
    <property name="ValueType" type="System.String"/>
  </composite-element>
</map>   
其映射文件如下所示:

public class WfStep
{
    private readonly IDictionary properties = new Hashtable();

    public virtual Guid Id { get; private set; }
    public virtual string Name { get; set; }
    public virtual dynamic Properties { get { return new HashtableDynamicObject(properties); } }
<class name="ConsoleApplication4.WfStep" table="WFSteps">

<id name="Id">
  <generator class="guid"/>
</id>
<property name="Name" />

<map name="Properties" table="WFSteps_Properties" access="field.lowercase">
  <key column="StepId" />
  <index column="PropertyName" type="System.String"/>
  <composite-element class="ConsoleApplication4.ValueItem, ConsoleApplication4">
    <property name="Value" type="System.String"/>
    <property name="ValueType" type="System.String"/>
  </composite-element>
</map>   
现在我想返回DateProperty设置为2010年的所有WFSteps,即:

var Session.Query<WfStep>().Where(x=>x.Properties.DateProperty.Year == 2010);
var Session.Query()。其中(x=>x.Properties.DateProperty.Year==2010);
它抛出一个错误:

表达式树不能包含动态操作


如何查询这种具有动态属性的类

您可以为映射为映射或列表的集合编制索引。尝试以下hql

from WfStep s
where s.Properties["DateProperty"] = "2010"

问题是我不想为此使用hql。只有QueryOver或Linq。您是否尝试过执行
。其中(x=>x.Properties[“DateProperty”]=“2010”)