@@ -1281,7 +1281,7 @@ public TSelect DisableGlobalFilter(params string[] name)
12811281 }
12821282 return this as TSelect ;
12831283 }
1284- public TSelect ForUpdate ( bool noawait = false )
1284+ public TSelect ForUpdate ( bool noawait = false , bool skipLocked = false )
12851285 {
12861286 if ( _transaction == null && _orm . Ado . TransactionCurrentThread != null ) this . WithTransaction ( _orm . Ado . TransactionCurrentThread ) ;
12871287 if ( _transaction == null && _resolveHookTransaction != null ) this . WithTransaction ( _resolveHookTransaction ( ) ) ;
@@ -1291,25 +1291,25 @@ public TSelect ForUpdate(bool noawait = false)
12911291 case DataType . MySql :
12921292 case DataType . OdbcMySql :
12931293 case DataType . CustomMySql :
1294- _tosqlAppendContent = $ "{ _tosqlAppendContent } for update";
1294+ _tosqlAppendContent = $ "{ _tosqlAppendContent } for update{ ( skipLocked ? " skip locked" : "" ) } ";
12951295 break ;
12961296 case DataType . SqlServer :
12971297 case DataType . OdbcSqlServer :
12981298 case DataType . CustomSqlServer :
1299- _aliasRule = ( _ , old ) => $ "{ old } With(UpdLock, RowLock{ ( noawait ? ", NoWait" : "" ) } )";
1299+ _aliasRule = ( _ , old ) => $ "{ old } With(UpdLock, RowLock{ ( noawait ? ", NoWait" : "" ) } { ( skipLocked ? ", ReadPast" : "" ) } )";
13001300 break ;
13011301 case DataType . PostgreSQL :
13021302 case DataType . OdbcPostgreSQL :
13031303 case DataType . CustomPostgreSQL :
13041304 case DataType . KingbaseES :
13051305 case DataType . Xugu :
1306- _tosqlAppendContent = $ "{ _tosqlAppendContent } for update{ ( noawait ? " nowait" : "" ) } ";
1306+ _tosqlAppendContent = $ "{ _tosqlAppendContent } for update{ ( noawait ? " nowait" : "" ) } { ( skipLocked ? " skip locked" : "" ) } ";
13071307 break ;
13081308 case DataType . Oracle :
13091309 case DataType . OdbcOracle :
13101310 case DataType . CustomOracle :
13111311 case DataType . Dameng :
1312- _tosqlAppendContent = $ "{ _tosqlAppendContent } for update{ ( noawait ? " nowait" : "" ) } ";
1312+ _tosqlAppendContent = $ "{ _tosqlAppendContent } for update{ ( noawait ? " nowait" : "" ) } { ( skipLocked ? " skip locked" : "" ) } ";
13131313 break ;
13141314 case DataType . Sqlite :
13151315 break ;
0 commit comments