Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在数据库表/NHibernate 实体中有一个复合键。我可以以某种方式使用该.Get方法来获取特定实体,还是由于复合键而必须使用 HQL / Criteria?
.Get
使用此复合键映射:
<class name="MyClass"> <composite-id> <key-property name="Key1" /> <key-property name="Key2" /> </composite-id> <property name="..." /> </class>
...你可以使用 .Get 像这样:
var x = Session.Get<MyClass>(new MyClass() { Key1 = 'Foo', Key2 = 'Bar'});