4
I’m wondering which of the following approaches is best?
1 - Add a file *.sql
as Resource, then run the Sqlcommand with the CommandType.Text
.
2 - Add a Store Procedure to the Database, then run the Sqlcommand with the CommandType.StoredProcedure
.
The Resource with SQL and the Store Procudere have the same query and expect the same parameters.
In both cases, the parameters are added to the list of Parameters
of Sqlcommand and we don’t have SQL and C# mixed inside the file *.cs
.
In this scenario it is faster to run the Storeprocedude or Text?
You can, or better, should measure to know which is the fastest. There is no technical difference that alone determines which is the fastest. The best performance will depend on what this SQL command does and what you do with the result of it.
– Caffé
@Caffé, in case it would just read operations returning a list of objects.
– Tobias Mesquita