2
线配置FluentNHibernate,FluentMappings.AddFromAssembly;这意味着
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Product>()
它有什么作用?它是否会在从ClassMap派生的Product类的程序集中查找任何类?或者背后的逻辑是什么?我可以将这个程序集的任何随机类放在这里,并期望它能找到这个程序集中的所有映射类吗?
private static ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(Properties.Settings.Default.FnhDbString)
.Cache(c => c
.UseQueryCache()).ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Product>()
.Conventions.Add(FluentNHibernate.Conventions.Helpers.DefaultLazy.Never()))
.BuildSessionFactory();
}
也可以链在一起一个`凡()`方法之后,以指定班级必须符合的一些标准。 – 2011-01-27 10:59:40