我处于这种情况:
Table A
id
name
country
和国家表
Table Country
country
name
字段国家是 2 位数的 ISO(US、PA、UY 等)。表 A 中的字段 country 引用表 Country 中的字段 iso。我在(A 类和 Country 类)nHibernate 上创建了类,因为我没有我设置的所有国家not-found="ignore"。
Class A
string name;
Country country;
Class Country
string iso;
string name;
如果我想获得 ISO 代码,我将使用 y 类的 .net 属性A.country.iso。现在,如果我有一个不在表 Country 中的 ISO 代码,A.country.iso 将给出异常,因为 country 对象为空。但是表 A 的国家字段不为空,我想获取它们的值。
我怎样才能做到这一点?