我想使用 Example.Create() 仅通过实例的唯一值进行查询。为此,我需要找出映射文件中设置的唯一键属性的值,如下所示:
<property name="MyColumn">
<column name="MyColumn" unique-key="MyUniqueKeyGroup"/>
</property>
为了更好地理解 - 这是代码的重要部分:
criteria.Add(Example.Create(myObject).SetPropertySelector(new MyPropertySelector()));
[...]
public class MyPropertySelector: NHibernate.Criterion.Example.IPropertySelector
{
#region IPropertySelector Member
public bool Include(object propertyValue, string propertyName, IType type)
{
/* here is where I want to check if the property belongs
* to the unique-key group 'MyUniqueKeyGroup' and return true if so
*/
}
#endregion
}
我需要做什么才能确定某个属性是否属于唯一键组“MyUniqueKeyGroup”?