<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      通過(guò)屬性區(qū)分業(yè)務(wù)表 與主庫(kù)的區(qū)別

       /// <summary>
          /// 初始化數(shù)據(jù)庫(kù)
          /// </summary>
          /// <param name="db"></param>
          /// <param name="config"></param>
          private static void InitDatabase(SqlSugarScope db, DbConnectionConfig config)
          {
              SqlSugarScopeProvider dbProvider = db.GetConnectionScope(config.ConfigId);
      
              // 初始化/創(chuàng)建數(shù)據(jù)庫(kù)
              if (config.DbSettings.EnableInitDb)
              {
                  if (config.DbType != SqlSugar.DbType.Oracle)
                      dbProvider.DbMaintenance.CreateDatabase();
              }
      
              // 初始化表結(jié)構(gòu)
              if (config.TableSettings.EnableInitTable)
              {
                  var entityTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.IsDefined(typeof(SugarTable), false))
                      .WhereIF(config.TableSettings.EnableIncreTable, u => u.IsDefined(typeof(IncreTableAttribute), false)).ToList();
                  //var infos1 = entityTypes.Where(u => u.GetCustomAttributes<SysTableAttribute>().Any()).ToList();
                 // var infos = entityTypes.Where(u => u.GetCustomAttributes<TenantAttribute>().Any()).ToList();
                  if (config.ConfigId.ToString() == SqlSugarConst.MainConfigId) // 默認(rèn)庫(kù)(有系統(tǒng)表特性、沒(méi)有日志表和租戶表特性)
                      entityTypes = entityTypes.Where(u => u.GetCustomAttributes<SysTableAttribute>().Any()/* || (!u.GetCustomAttributes<LogTableAttribute>().Any() && !u.GetCustomAttributes<TenantAttribute>().Any())*/).ToList();
                  else if (config.ConfigId.ToString() == SqlSugarConst.LogConfigId) // 日志庫(kù)
                      entityTypes = entityTypes.Where(u => u.GetCustomAttributes<LogTableAttribute>().Any()).ToList();
                  else
                      entityTypes = entityTypes.Where(u => u.GetCustomAttribute<TenantAttribute>()?.configId.ToString() == config.ConfigId.ToString()).ToList(); // 自定義的庫(kù)
      
                  foreach (var entityType in entityTypes)
                  {
                      if (entityType.GetCustomAttribute<SplitTableAttribute>() == null)
                          dbProvider.CodeFirst.InitTables(entityType);
                      else
                          dbProvider.CodeFirst.SplitTables().InitTables(entityType);
                  }
              }
      
              // 初始化種子數(shù)據(jù)
              if (config.SeedSettings.EnableInitSeed)
              {
                  var seedDataTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>))))
                      .WhereIF(config.SeedSettings.EnableIncreSeed, u => u.IsDefined(typeof(IncreSeedAttribute), false)).ToList();
      
                  foreach (var seedType in seedDataTypes)
                  {
                      var entityType = seedType.GetInterfaces().First().GetGenericArguments().First();
                      if (config.ConfigId.ToString() == SqlSugarConst.MainConfigId) // 默認(rèn)庫(kù)(有系統(tǒng)表特性、沒(méi)有日志表和租戶表特性)
                      {
                          if (entityType.GetCustomAttribute<SysTableAttribute>() == null && (entityType.GetCustomAttribute<LogTableAttribute>() != null || entityType.GetCustomAttribute<TenantAttribute>() != null))
                              continue;
                      }
                      else if (config.ConfigId.ToString() == SqlSugarConst.LogConfigId) // 日志庫(kù)
                      {
                          if (entityType.GetCustomAttribute<LogTableAttribute>() == null)
                              continue;
                      }
                      else
                      {
                          var att = entityType.GetCustomAttribute<TenantAttribute>(); // 自定義的庫(kù)
                          if (att == null || att.configId.ToString() != config.ConfigId.ToString()) continue;
                      }
      
                      var instance = Activator.CreateInstance(seedType);
                      var hasDataMethod = seedType.GetMethod("HasData");
                      var seedData = ((IEnumerable)hasDataMethod?.Invoke(instance, null))?.Cast<object>();
                      if (seedData == null) continue;
      
                      var entityInfo = dbProvider.EntityMaintenance.GetEntityInfo(entityType);
                      if (entityInfo.Columns.Any(u => u.IsPrimarykey))
                      {
                          // 按主鍵進(jìn)行批量增加和更新
                          var storage = dbProvider.StorageableByObject(seedData.ToList()).ToStorage();
                          storage.AsInsertable.ExecuteCommand();
                          storage.AsUpdateable.ExecuteCommand();
                      }
                      else
                      {
                          // 無(wú)主鍵則只進(jìn)行插入
                          if (!dbProvider.Queryable(entityInfo.DbTableName, entityInfo.DbTableName).Any())
                              dbProvider.InsertableByObject(seedData.ToList()).ExecuteCommand();
                      }
                  }
              }
          }

       

      posted on 2024-03-15 10:04  小石頭的一天  閱讀(280)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 熟女精品视频一区二区三区| 国产熟睡乱子伦视频在线播放| 亚洲人妻av伦理| 欧美搡bbbbb搡bbbbb| 久久亚洲综合精品成人网| 日韩秘 无码一区二区三区 | 国产高清精品在线一区二区| 免费久久人人爽人人爽AV| 亚洲色大成网站WWW久久| 中文字幕人妻中出制服诱惑| 又粗又紧又湿又爽的视频| 88国产精品视频一区二区三区| 日区中文字幕一区二区| 麻豆果冻国产剧情av在线播放| 国内极度色诱视频网站| 国产精品疯狂输出jk草莓视频| 国产精品乱人伦一区二区| 国产精品ⅴ无码大片在线看| 国产麻豆精品手机在线观看| 国内精品一区二区不卡| 亚洲乱亚洲乱妇50p| 色综合天天综合网中文伊| 国产精品久久蜜臀av| 免费大片av手机看片高清| 临武县| 国产伦码精品一区二区| 午夜激情小视频一区二区| 久久精品国产99久久6| 国产一区二区三区黄色片| 亚洲 日本 欧洲 欧美 视频| 人妻内射一区二区在线视频| 色综合一本到久久亚洲91| 成人自拍小视频免费观看| 亚洲精品入口一区二区乱| 免费福利视频一区二区三区高清| 成人午夜免费无码视频在线观看| 人妻一本久道久久综合鬼色| 人妻在线无码一区二区三区| 女人香蕉久久毛毛片精品| 亚洲一二三区精品美妇| 内射极品少妇xxxxxhd|