在EF中执行Sql语句. using (var context = new EFRecipesEntities()) { string sql = @"insert into Chapter3.Payment(Amount, Vendor) values (@Amount, @Vendor)"; var args = new DbParameter[] { new SqlParameter { ParameterName = "Amount", Value = 99…
1 使用原生SQL语句更新--Database.ExecuteSqlCommand 假设你有一张如图9-1所示的Payment数据库表. 图9-1 1.1 实体类型: public class Payment { public int PaymentId { get; set; } public decimal Amount { get; set; } public string Vendor { get; set; } } 1.2 数据访问类: public class EF6RecipesC…