@@ -63,6 +63,14 @@ WHERE EXISTS ( SELECT 1 FROM ({Select}) B
6363 internal const string CommandTextTemplate_PostgreSQL = @"
6464UPDATE {TableName}
6565SET {SetValue}
66+ WHERE EXISTS ( SELECT 1 FROM ({Select}) B
67+ WHERE {PrimaryKeys}
68+ )
69+ " ;
70+
71+ internal const string CommandTextTemplate_SQLite = @"
72+ UPDATE {TableName}
73+ SET {SetValue}
6674WHERE EXISTS ( SELECT 1 FROM ({Select}) B
6775 WHERE {PrimaryKeys}
6876 )
@@ -316,6 +324,7 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
316324 var isSqlCe = command . GetType ( ) . Name == "SqlCeCommand" ;
317325 var isOracle = command . GetType ( ) . Namespace . Contains ( "Oracle" ) ;
318326 var isPostgreSQL = command . GetType ( ) . Name == "NpgsqlCommand" ;
327+ var isSQLite = command . GetType ( ) . Namespace . Contains ( "SQLite" ) ;
319328
320329 // Oracle BindByName
321330 if ( isOracle )
@@ -353,6 +362,10 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
353362 string . Concat ( "\" " , store . Table , "\" " ) :
354363 string . Concat ( "\" " , store . Schema , "\" .\" " , store . Table , "\" " ) ;
355364 }
365+ else if ( isSQLite )
366+ {
367+ tableName = string . Concat ( "\" " , store . Table , "\" " ) ;
368+ }
356369 else
357370 {
358371 tableName = string . IsNullOrEmpty ( store . Schema ) ?
@@ -388,6 +401,7 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
388401 isOracle ? CommandTextOracleTemplate :
389402 isMySql ? CommandTextTemplate_MySQL :
390403 isSqlCe ? CommandTextTemplateSqlCe :
404+ isSQLite ? CommandTextTemplate_SQLite :
391405 CommandTextTemplate ;
392406
393407 // GET inner query
@@ -421,6 +435,15 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
421435 string . Concat ( EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL ) , " = " , ( ( ConstantExpression ) x . Item2 ) . Value ) :
422436 string . Concat ( EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL ) , " = :zzz_BatchUpdate_" , i ) ) ) ;
423437 }
438+ else if ( isSQLite )
439+ {
440+ primaryKeys = string . Join ( Environment . NewLine + "AND " , columnKeys . Select ( x => string . Concat ( EscapeName ( x , isMySql , isOracle , isPostgreSQL ) , " = B." , EscapeName ( x , isMySql , isOracle , isPostgreSQL ) , "" ) ) ) ;
441+
442+ // GET updateSetValues
443+ setValues = string . Join ( "," + Environment . NewLine , values . Select ( ( x , i ) => x . Item2 is ConstantExpression ?
444+ string . Concat ( EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL ) , " = " , ( ( ConstantExpression ) x . Item2 ) . Value ) :
445+ string . Concat ( EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL ) , " = @zzz_BatchUpdate_" , i ) ) ) ;
446+ }
424447 else
425448 {
426449 primaryKeys = string . Join ( Environment . NewLine + "AND " , columnKeys . Select ( x => string . Concat ( "A." , EscapeName ( x , isMySql , isOracle , isPostgreSQL ) , " = B." , EscapeName ( x , isMySql , isOracle , isPostgreSQL ) , "" ) ) ) ;
0 commit comments