@@ -34,7 +34,12 @@ private static EntityInfo GetEntityInfo<T>(DbContext dbContext)
3434 . GetProperties ( )
3535 . Select ( x =>
3636 {
37+ #if NET7_0_OR_GREATER
3738 var name = x . GetColumnName ( ) ;
39+ #else
40+ var storeObjectIdentifier = StoreObjectIdentifier . Table ( tableName , schema ) ;
41+ var name = x . GetColumnName ( storeObjectIdentifier ) ;
42+ #endif
3843 var refName = x . Name ;
3944 var isIdentity = x . ValueGenerated == ValueGenerated . OnAddOrUpdate ;
4045 var skipInsert = x . ValueGenerated == ValueGenerated . OnAddOrUpdate ;
@@ -43,7 +48,7 @@ private static EntityInfo GetEntityInfo<T>(DbContext dbContext)
4348 var isPrimaryKey = x . IsPrimaryKey ( ) ;
4449 var isKey = x . IsKey ( ) ;
4550
46- return new ColumnInfo ( name , refName , isPrimaryKey , isUniqueIndex , isKey , isIdentity , skipInsert ,
51+ return new ColumnInfo ( name ! , refName , isPrimaryKey , isUniqueIndex , isKey , isIdentity , skipInsert ,
4752 skipUpdate )
4853 {
4954 ValueConverter = x . GetValueConverter ( )
@@ -59,9 +64,9 @@ private static EntityInfo GetEntityInfo<T>(DbContext dbContext)
5964 /// </summary>
6065 private static string [ ] GetExpressionFields < T > ( Expression < Func < T , object > > ? expression )
6166 {
62- if ( expression is null ) return [ ] ;
67+ if ( expression is null ) return Array . Empty < string > ( ) ;
6368 var instance = JsonSerializer . Deserialize < T > ( "{}" ) ;
64- if ( instance is null ) return [ ] ;
69+ if ( instance is null ) return Array . Empty < string > ( ) ;
6570
6671 var expr = expression . Compile ( ) ;
6772 var anonymousInstance = expr . Invoke ( instance ) ;
@@ -82,10 +87,10 @@ internal static List<BatchData> GenerateInsertBatches<T>(DbContext dbContext, IR
8287 BulkOption < T > ? option )
8388 where T : class
8489 {
85- if ( items . Count == 0 ) return [ ] ;
90+ if ( items . Count == 0 ) return new List < BatchData > ( ) ;
8691
8792 var info = GetEntityInfo < T > ( dbContext ) ;
88- string [ ] ignoreFields = [ ] ;
93+ string [ ] ignoreFields = Array . Empty < string > ( ) ;
8994 if ( option ? . IgnoreOnInsert is not null ) ignoreFields = GetExpressionFields ( option . IgnoreOnInsert ) ;
9095
9196 var columns = info . Columns
@@ -101,7 +106,7 @@ internal static List<BatchData> GenerateInsertBatches<T>(DbContext dbContext, IR
101106 . Select ( rows =>
102107 {
103108 var tmpTable = ToTempTable ( columns , rows , offset ) ;
104- if ( tmpTable is null ) return new BatchData ( new StringBuilder ( ) , [ ] ) ;
109+ if ( tmpTable is null ) return new BatchData ( new StringBuilder ( ) , new List < SqlParameter > ( ) ) ;
105110
106111 tmpTable . Sql . Insert ( 0 ,
107112 @$ "INSERT INTO `{ info . TableName } `
@@ -129,10 +134,10 @@ internal static List<BatchData> GenerateUpdateBatches<T>(DbContext dbContext, IR
129134 BulkOption < T > ? option )
130135 where T : class
131136 {
132- if ( items . Count == 0 ) return [ ] ;
137+ if ( items . Count == 0 ) return new List < BatchData > ( ) ;
133138 var info = GetEntityInfo < T > ( dbContext ) ;
134139
135- string [ ] ignoreFields = [ ] ;
140+ string [ ] ignoreFields = Array . Empty < string > ( ) ;
136141 if ( option ? . IgnoreOnUpdate is not null ) ignoreFields = GetExpressionFields ( option . IgnoreOnUpdate ) ;
137142
138143 var columns = info . Columns
@@ -148,7 +153,7 @@ internal static List<BatchData> GenerateUpdateBatches<T>(DbContext dbContext, IR
148153 . Select ( rows =>
149154 {
150155 var tmpTable = ToTempTable ( columns , rows , offset ) ;
151- if ( tmpTable is null ) return new BatchData ( new StringBuilder ( ) , [ ] ) ;
156+ if ( tmpTable is null ) return new BatchData ( new StringBuilder ( ) , new List < SqlParameter > ( ) ) ;
152157
153158 tmpTable . Sql . Insert ( 0 ,
154159 @$ "UPDATE `{ info . TableName } ` AS tb
@@ -194,7 +199,7 @@ internal static List<BatchData> GenerateDeleteBatches<T>(DbContext dbContext, IR
194199 BulkOption < T > ? option )
195200 where T : class
196201 {
197- if ( items . Count == 0 ) return [ ] ;
202+ if ( items . Count == 0 ) return new List < BatchData > ( ) ;
198203 var info = GetEntityInfo < T > ( dbContext ) ;
199204
200205 List < ColumnInfo > columns ;
@@ -223,7 +228,7 @@ internal static List<BatchData> GenerateDeleteBatches<T>(DbContext dbContext, IR
223228 . Select ( rows =>
224229 {
225230 var tmpTable = ToTempTable ( columns , rows , offset ) ;
226- if ( tmpTable is null ) return new BatchData ( new StringBuilder ( ) , [ ] ) ;
231+ if ( tmpTable is null ) return new BatchData ( new StringBuilder ( ) , new List < SqlParameter > ( ) ) ;
227232
228233 tmpTable . Sql . Insert ( 0 ,
229234 @$ "DELETE tb
@@ -257,18 +262,18 @@ internal static List<BatchData> GenerateMergeBatches<T>(DbContext dbContext,
257262 BulkOption < T > ? option )
258263 where T : class
259264 {
260- if ( items . Count == 0 ) return [ ] ;
265+ if ( items . Count == 0 ) return new List < BatchData > ( ) ;
261266
262267 var info = GetEntityInfo < T > ( dbContext ) ;
263- string [ ] ignoreInsertFields = [ ] ;
268+ string [ ] ignoreInsertFields = Array . Empty < string > ( ) ;
264269 if ( option ? . IgnoreOnInsert is not null ) ignoreInsertFields = GetExpressionFields ( option . IgnoreOnInsert ) ;
265270 var insertCols = info . Columns
266271 . Where ( x => x is { SkipInsert : false }
267272 && ! ignoreInsertFields . Contains ( x . RefName )
268273 )
269274 . ToList ( ) ;
270275
271- string [ ] ignoreUpdateFields = [ ] ;
276+ string [ ] ignoreUpdateFields = Array . Empty < string > ( ) ;
272277 if ( option ? . IgnoreOnUpdate is not null ) ignoreUpdateFields = GetExpressionFields ( option . IgnoreOnUpdate ) ;
273278 var updateCols = info . Columns
274279 . Where ( x => x is { IsPrimaryKey : false , IsUniqueIndex : false , SkipUpdate : false }
@@ -288,7 +293,7 @@ internal static List<BatchData> GenerateMergeBatches<T>(DbContext dbContext,
288293 . Select ( rows =>
289294 {
290295 var tmpTable = ToTempTable ( combineColumns , rows , offset ) ;
291- if ( tmpTable is null ) return new BatchData ( new StringBuilder ( ) , [ ] ) ;
296+ if ( tmpTable is null ) return new BatchData ( new StringBuilder ( ) , new List < SqlParameter > ( ) ) ;
292297
293298 tmpTable . Sql . Insert ( 0 ,
294299 @$ "INSERT INTO `{ info . TableName } `
@@ -325,13 +330,13 @@ internal static List<BatchData> GenerateMergeBatches<T>(DbContext dbContext,
325330 where T : class
326331 {
327332 if ( rows . Count == 0 ) return null ;
328- List < SqlParameter > parameters = [ ] ;
333+ List < SqlParameter > parameters = new List < SqlParameter > ( ) ;
329334 var sql = new StringBuilder ( "(" ) ;
330335 sql . AppendLine ( ) ;
331336 rows . ForEachWithIndex ( ( row , rowIndex ) =>
332337 {
333338 sql . Append ( rowIndex == 0 ? "SELECT " : "UNION ALL SELECT " ) ;
334- List < SqlParameter > list = [ ] ;
339+ List < SqlParameter > list = new List < SqlParameter > ( ) ;
335340 var type = row . GetType ( ) ;
336341 var colIndex = 0 ;
337342 columns . ToList ( ) . ForEach ( column =>
0 commit comments