编程语言
首页 > 编程语言> > C#_EFCore学习

C#_EFCore学习

作者:互联网

1、批量增加,删除,更新

包:Zack.EFCore.Batch

//增加
ctx.BulkInsert(books)

//删除
await ctx.DeleteRangeAsync<Book>(b=>b.Price>n||b.AuthorName=="Diff");

//更新Set(b=>b.Key,b.value)
await ctx.BatchUpdate<Book>()
    .Set(b=>b.Price,b.Price+3)
   	.Set(b=>b.Title,b=>s)
    .Set(b=>b.AuthorName,b=>b.Title.Substring(3,2)+b.AuthorName.ToUpper())
    .Set(b=>b.PubTime,b=>DateTime.Now)
    .Where(b=>b.Id>n||b.ArthorName.StartsWith("Diff")).ExecuteAsync()    

标签:Set,Title,C#,Price,ctx,学习,AuthorName,EFCore
来源: https://www.cnblogs.com/diffknow/p/16653200.html