2
What is the difference between Executequery, Sqlquery and Executesqlcommand?
When I know which one to use?
2
What is the difference between Executequery, Sqlquery and Executesqlcommand?
When I know which one to use?
6
Executesqlcommand: Executes a command, not for queries, or you will use to INSERT
/UPDATE
/DELETE
.
Executequery: Execute a query with parameter, first receiving the Query and then the parameters as in the following example:
db.ExecuteQuery<Customer>(@"SELECT CustomerID, CompanyName, ContactName, ContactTitle,Address, City,
Region, PostalCode, Country, Phone, Fax FROM dbo.Customers WHERE City = {0}", "London");
Sqlquery: Executes a query (without passing parameters securely as in ExecuteQuery
.
Note that ExecuteQuery
is much like SqlQuery
but it is recommended for safety to use it whenever you consult using parameters.
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
Executequery and Sqlquery are used to execute standard SQL queries, a select and the like, since Executesqlcommand is mostly used to perform Update,Insert,Delete actions..
– João Paulo Amorim