请输入图片描述

引入命名空间:using EntityFramework.Extensions; 然后调用该Update方法

var products = ctx.Products.Update(x => new Product { Name = x.Name + "777" });
ctx.SaveChanges();

捕获到SQL语句是这样的,很奇怪用ctx.Database.Log = Console.WriteLine;捕获不到,我用的SQL Profiler,这应该是这个Extended库是第三方的原因,不是EF团队弄的

UPDATE [dbo].[tb_Products] SET 
[Name] = CASE WHEN ([Name] IS NULL) THEN N'' ELSE [Name] END + N'777'  
FROM [dbo].[tb_Products] AS j0 INNER JOIN (
SELECT 
    1 AS [C1], 
    [Extent1].[Id] AS [Id]
    FROM [dbo].[tb_Products] AS [Extent1]
) AS j1 ON (j0.[Id] = j1.[Id])

看看数据库里面

请输入图片描述