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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -