Beispiel #1
0
            public override Task Persistent()
            {
                var res = FreeSqlDb.Insert(this);

                res.ExecuteInserted();
                return(Task.CompletedTask);
            }
Beispiel #2
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            Fsql = FreeSqlDb.Builder(Configuration);
            Fsql.Aop.CurdAfter += (s, e) =>
            {
                if (e.ElapsedMilliseconds > 1000)
                {
                    //打印高耗时的sql
                    Debug.WriteLine($"耗时:{e.ElapsedMilliseconds}ms,SQL:{e.Sql}");
                }
            };

            NLog.GlobalDiagnosticsContext.Set("DefaultConnection", Configuration.GetConnectionString("SqlConnection"));
        }
Beispiel #3
0
 public void Configure(IWebHostBuilder builder)
 {
     builder.ConfigureServices((context, services) =>
     {
         services.AddFreeSql(options =>
         {
             var db = new FreeSqlDb()
             {
                 Name                   = "FreeSqlDb",
                 DataType               = DataType.MySql,
                 ConnectString          = "Server=coobeedior.com;Database=log;User=root;Password=root;",
                 IsAutoSyncStructure    = true,
                 IsNoneCommandParameter = false,
                 IsLazyLoading          = false,
                 NameConvertType        = NameConvertType.PascalCaseToUnderscoreWithLower,
                 Executing              = (command) => { },
                 Executed               = (command, sql) => { }
             };
             options.FreeSqlDbs.Add(db);
         });
     });
 }