File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,10 @@ private bool IsDirty
155155 // @TODO: IsPrepared is part of IsDirty - this is confusing.
156156 private bool IsUserPrepared => IsPrepared && ! _hiddenPrepare && ! IsDirty ;
157157
158+ private bool IsStoredProcedure => CommandType is CommandType . StoredProcedure ;
159+
160+ private bool IsSimpleTextQuery => CommandType is CommandType . Text && _parameters ? . Count == 0 ;
161+
158162 #endregion
159163
160164 #region Public/Internal Methods
@@ -182,11 +186,9 @@ public override void Prepare()
182186 {
183187 statistics = SqlStatistics . StartTimer ( Statistics ) ;
184188
185- // Only prepare batch has parameters
186- // @TODO: Factor out stored proc/text+parameter count to property
187- // @TODO: Not using parentheses is confusing here b/c it relies on order of operations knowledge
188- if ( IsPrepared && ! IsDirty || CommandType == CommandType . StoredProcedure
189- || ( CommandType == CommandType . Text && GetParameterCount ( _parameters ) == 0 ) )
189+ // Only prepare batch that has parameters
190+ // @TODO: IsPrepared is part of IsDirty - this is confusing.
191+ if ( ( IsPrepared && ! IsDirty ) || IsStoredProcedure || IsSimpleTextQuery )
190192 {
191193 // @TODO: Make a simpler SafeIncrementPrepares
192194 Statistics ? . SafeIncrement ( ref Statistics . _prepares ) ;
You can’t perform that action at this time.
0 commit comments