@@ -1807,13 +1807,14 @@ public virtual string QuoteIdentifier(params string[] names)
18071807 /// <returns>String containing the whole batch.</returns>
18081808 public virtual string BuildBatch ( string [ ] statements )
18091809 {
1810- if ( statements . Length == 0 )
1810+ if ( statements . Length == 0 ) {
18111811 return string . Empty ;
1812- var statementEndingLength = BatchItemDelimiter . Length + NewLine . Length ;
1813- var expectedLength = BatchBegin . Length + BatchEnd . Length +
1814- statements . Sum ( statement => statement . Length + statementEndingLength ) ;
1812+ }
1813+ var expectedLength = BatchBegin . Length + BatchEnd . Length
1814+ + ( ( BatchItemDelimiter . Length + NewLine . Length ) * statements . Length )
1815+ + statements . Sum ( statement => statement . Length ) ;
18151816 var builder = new StringBuilder ( expectedLength ) ;
1816- builder . Append ( BatchBegin ) ;
1817+ _ = builder . Append ( BatchBegin ) ;
18171818 foreach ( var statement in statements ) {
18181819 var actualStatement = statement
18191820 . TryCutPrefix ( BatchBegin )
@@ -1823,11 +1824,11 @@ public virtual string BuildBatch(string[] statements)
18231824 . Trim ( ) ;
18241825 if ( actualStatement . Length == 0 )
18251826 continue ;
1826- builder . Append ( actualStatement ) ;
1827- builder . Append ( BatchItemDelimiter ) ;
1828- builder . Append ( NewLine ) ;
1827+ _ = builder . Append ( actualStatement )
1828+ . Append ( BatchItemDelimiter )
1829+ . Append ( NewLine ) ;
18291830 }
1830- builder . Append ( BatchEnd ) ;
1831+ _ = builder . Append ( BatchEnd ) ;
18311832 return builder . ToString ( ) ;
18321833 }
18331834
0 commit comments