@@ -32,7 +32,7 @@ public class TemporaryTableManager : DomainBoundHandler
3232 /// <summary>
3333 /// Gets value indicating whether temporary tables are supported.
3434 /// </summary>
35- public bool Supported { get { return backEnd != null ; } }
35+ public bool Supported { get { return backEnd != null ; } }
3636
3737 /// <summary>
3838 /// Builds the descriptor of a temporary table.
@@ -93,10 +93,13 @@ public TemporaryTableDescriptor BuildDescriptor(ModelMapping modelMapping, strin
9393 LazyLevel1BatchStoreRequest = CreateLazyPersistRequest ( WellKnown . MultiRowInsertLevel1BatchSize ) ,
9494 LazyLevel2BatchStoreRequest = CreateLazyPersistRequest ( WellKnown . MultiRowInsertLevel2BatchSize ) ,
9595 LazyStoreRequest = CreateLazyPersistRequest ( 1 ) ,
96- ClearRequest = new PersistRequest ( driver , Handlers . ProviderInfo . Supports ( ProviderFeatures . TruncateTable ) ? SqlDdl . Truncate ( table ) : SqlDml . Delete ( tableRef ) , null )
96+ ClearRequest = new Lazy < PersistRequest > ( ( ) => {
97+ var request = new PersistRequest ( driver , Handlers . ProviderInfo . Supports ( ProviderFeatures . TruncateTable ) ? SqlDdl . Truncate ( table ) : SqlDml . Delete ( tableRef ) , null ) ;
98+ request . Prepare ( ) ;
99+ return request ;
100+ } )
97101 } ;
98102
99- result . ClearRequest . Prepare ( ) ;
100103 return result ;
101104
102105 Lazy < PersistRequest > CreateLazyPersistRequest ( int batchSize ) =>
@@ -147,7 +150,7 @@ protected void ExecuteNonQuery(EnumerationContext context, string statement)
147150 private static TemporaryTableStateRegistry GetRegistry ( Session session )
148151 {
149152 var registry = session . Extensions . Get < TemporaryTableStateRegistry > ( ) ;
150- if ( registry == null ) {
153+ if ( registry == null ) {
151154 registry = new TemporaryTableStateRegistry ( ) ;
152155 session . Extensions . Set ( registry ) ;
153156 }
@@ -167,7 +170,7 @@ private string[] BuildFieldNames(TupleDescriptor source) =>
167170 . Select ( i => string . Format ( ColumnNamePattern , i ) )
168171 . ToArray ( ) ;
169172
170- private Table CreateTemporaryTable ( Schema schema , string name , TupleDescriptor source , TypeMapping [ ] typeMappings , string [ ] fieldNames , Collation collation )
173+ private Table CreateTemporaryTable ( Schema schema , string name , TupleDescriptor source , TypeMapping [ ] typeMappings , string [ ] fieldNames , Collation collation )
171174 {
172175 var tableName = Handlers . NameBuilder . ApplyNamingRules ( string . Format ( TableNamePattern , name ) ) ;
173176 var table = backEnd . CreateTemporaryTable ( schema , tableName ) ;
@@ -178,7 +181,7 @@ private Table CreateTemporaryTable(Schema schema, string name, TupleDescriptor s
178181 var column = table . CreateColumn ( fieldNames [ fieldIndex ] , mapping . MapType ( ) ) ;
179182 column . IsNullable = true ;
180183 // TODO: Dmitry Maximov, remove this workaround than collation problem will be fixed
181- if ( mapping . Type == WellKnownTypes . String )
184+ if ( mapping . Type == WellKnownTypes . String )
182185 column . Collation = collation ;
183186 fieldIndex ++ ;
184187 }
0 commit comments