コード例 #1
0
        public static void BulkInsert <T>(this DbContext context, IEnumerable <T> entities, int batchSize = DefaultBatchSize)
        {
            var tempDbType = NS.Framework.Config.PlatformConfig.ServerConfig.DataBaseSetting.DataBaseType;

            if (string.IsNullOrEmpty(tempDbType))
            {
                throw new KeyNotFoundException("find data base settings error!");
            }

            switch (tempDbType)
            {
            case "mysql":
                var mySqlProvider = new MySQLBulkOperationProvider(context);
                mySqlProvider.Insert(entities, batchSize);
                break;

            case "sqlserver":
                var provider = new BulkOperationProvider(context);
                provider.Insert(entities, batchSize);
                break;

            case "oracle":
                break;
            }
        }
コード例 #2
0
        public static void BulkInsert <T>(this DbContext context, IEnumerable <T> entities, int batchSize = DefaultBatchSize)
        {
            var provider = new BulkOperationProvider(context);

            provider.Insert(entities, batchSize);
        }