我目前在nHibernate上切齿,并有一个关于动态访问我的持久对象中的属性的问题。在NHibernate中动态引用属性?
我在Domain
以下类:
public class Locations {
public virtual string CountryCode;
public virtual string CountryName;
}
现在,假设我有一个位置参考对象,有什么办法让我做这样的事情?
Locations myCountry = new LocationsRepository().GetByCountryCode("US");
myCountry.Set("CountryName", "U.S.A.");
,而不必做:
myCountry.CountryName = "U.S.A."
没有反映?
+1如果您使用Fastmember显示代码,您可能会获得更多投票。图书馆还很新。它可能有助于说明为什么你的答案实际上是最好的答案,并给人们一个尝试Fastmember的理由。 – jsmith