【发布时间】:2013-09-26 17:57:53
【问题描述】:
例如我有这样的表
表
ID -- CategotyID -- ProductName
1 --------- 4 ----------可口可乐
2 --------- 7 -- --------茶
3 --------- 4 ----------雪碧
当我在实体框架中编写此代码时:var list= db.Table.Where(w => w.CategotyID == 4).ToList();list.ForEach(update => update.ProductName = "Fanta");db.SaveChanges()
我在 SQL Profiler 中看到像这样单独执行此语句update Table set ProductName = "Fanta" where ID = 1update Table set ProductName = "Fanta" where ID = 3
我怎样才能从 SQL 写到 EntityFrameWork 这条语句?update Table set ProductName = "Fanta" where CategoryID = 4
不要让 SQL Server 单独执行它
【问题讨论】:
-
实体框架不支持这一点,但幸运的是,正如其他问题的答案所示,允许它的主要工作已经由其他人完成。
标签: c# mysql entity-framework entity-framework-4