首页 新闻 搜索 专区 学院

FluentNhibernate+.net core+sqlServer 2012+实体写入在.cs文件 配置问题

0
[已关闭问题] 关闭于 2019-06-14 14:38
            NHibernate.Cfg.Configuration setCfg(NHibernate.Cfg.Configuration c)
            {
                //c.Properties.Add("hbm2ddl.keywords", "none");
                c.Properties.Add("show_sql", "false");
                c.Properties.Add("adonet.batch_size", "100");
                c.Properties.Add("generate_statistics", "false");
                c.Properties.Add("format_sql", "true");
                c.Properties.Add("command_timeout", "60");
                c.Properties.Add("current_session_context_class", "web");
                return c;
            }

string connectionString = "Server=.,8013;Database=db;Uid=sa;Pwd=mypwd;";
var assemblyName = Assembly.Load("ClassMapping");
var _sessionFactory = Fluently.Configure().Database(MsSqlConfiguration.MsSql2012.ConnectionString(connectionString)
                        .Provider<NHibernate.Connection.DriverConnectionProvider>()
                        .Driver<NHibernate.Driver.Sql2008ClientDriver>())
                        .Mappings(m => m.FluentMappings.AddFromAssembly(assemblyName).ExportTo("c:\\"))
                        .ExposeConfiguration(c => setCfg(c))
                        .ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, false))
                        .ExposeConfiguration(f => f.SetInterceptor(new SqlStatementInterceptor()))
                        .BuildSessionFactory();
ClassMapping
namespace ClassMapping
{
    #region AgentsMap
    public class AgentMap : ClassMapping<Agent>
    {
        public AgentMap()
        {
            SelectBeforeUpdate(true);
            DynamicUpdate(true);

            Id(p => p.AgentId, map => map.Generator(Generators.Native));
            Version(p => p.Version, map => { });

            Property(p => p.StateId);
        }
    }
}

vs生成时不提示报错,但是在查询时,查询不到数据



wpzblog的主页 wpzblog | 初学一级 | 园豆:32
提问于:2019-06-14 14:17
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册