可能重复:
How to tell Fluent NHibernate not to map a class property
如何忽略属性People被映射? 代码将有助于。
public class Staff : IStaff
{
public virtual DateTime DateAdded { get; set; }
public virtual DateTime DateUpdated { get; set; }
public virtual int StaffID { get; set; }
public virtual int PersonID { get; set; }
public virtual Guid CreatedBy { get; set; }
public virtual Guid ModifiedBy { get; set; }
public virtual bool IsActive { get; set; }
public virtual bool IsDeleted { get; set; }
public virtual bool IsATeachingStaff { get; set; }
//This is the property I want to exclude from mapping
public virtual IPeople People { get; set; }
}
private static ISessionFactory CreateSessionFactory()
{
string ConnectionString = "Data Source=DELL;Initial Catalog=University;Integrated Security=True";
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(ConnectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<School.Business.lib.FHibernate.Mapper.PeopleMap>().ExportTo(@"c:\log"))
.ExposeConfiguration(BuildSchema)
.BuildSessionFactory();
}
public class StaffMap : ClassMap<Staff>
{
public StaffMap()
{
Table("Staff");
LazyLoad();
Id(x => x.StaffID).GeneratedBy.Identity().Column("StaffID");
Map(x => x.PersonID).Column("PersonID");
Map(x => x.DateAdded).Not.Nullable().Column("DateAdded");
Map(x => x.DateUpdated).Not.Nullable().Column("DateUpdated");
Map(x => x.CreatedBy).Not.Nullable().Column("CreatedBy");
Map(x => x.ModifiedBy).Not.Nullable().Column("ModifiedBy");
Map(x => x.IsActive).Column("IsActive");
Map(x => x.IsDeleted).Column("IsDeleted");
Map(x => x.IsATeachingStaff).Column("IsATeachingStaff");
}
}