23
我有一個映射在流利的nhibernate類,但我想要其中一個類屬性被映射忽略。如何告訴流利的NHibernate不要映射類屬性
隨着類和映射下面我得到這個錯誤:
以下類型可能不被用作代理: iMasterengine.Data.Model.Calendar:方法get_HasEvents應該虛擬
//my class
public class Calendar : IEntity {
public virtual int Id { get; private set; }
public virtual string Name { get; set; }
public virtual string SiteId { get; set; }
public virtual IList<CalendarEvent> Events { get; set; }
//ignore this property
public bool HasEvents { get { return Events.Count > 0; } }
}
//my mapping
public class CalendarMap : ClassMap<Calendar> {
public CalendarMap() {
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.SiteId);
HasMany(x => x.Events).Inverse();
//what do I put here to tell nhibernate
//to ignore my HasEvents property?
}
}
該行應該放在哪裏?我想它會進入CalendarMap構造函數,但我沒有看到可用的地圖實例。 – ddc0660 2009-10-19 15:07:11
應該在創建配置的位置添加它。請參閱此鏈接[http://wiki.fluentnhibernate.org/Auto_mapping#Ignoring_properties](http://wiki.fluentnhibernate.org/Auto_mapping#Ignoring_properties) – Rajeesh 2011-02-16 05:27:28