c# - How would I add a parameter to entity framework raw sql command -
how add parameter following entity framework raw sql command? example, if wanted make id
parameter?
using (var context = new northwinddbentities()) { context.database.executesqlcommand(@" update dbo.customers set name = 'test' id = 1 "); }
context.database.executesqlcommand(@"update dbo.customers set name = 'test' id = @id", new sqlparameter("id", 1));
in case of multiple parameters
context.database.executesqlcommand(@"update dbo.customers set name = 'test' id = @id , name =@name", new sqlparameter("id", id), new sqlparameter("name", fname));
Comments
Post a Comment