EntityFramework扩展之第三方类库

时间:2020-12-15 23:57:32

EntityFramework 非常好用,结构优美.. 但是美中有不足:1.对动态查询条件支持的不是很好 ;2.批量操作支持的不是很好.。
下面就是几个第三方库,对EntityFramework 的扩展

一、第三方类库

LinqKit

动态拼装查询条件

开源地址:https://github.com/scottksmith95/LINQKit

Entity Framework Extensions

(收费)Website: http://entityframework-extensions.net/

Paid library to dramatically improve Entity Framework performance:

  • BulkSaveChanges
  • BulkInsert
  • BulkUpdate
  • BulkDelete
  • BulkMerge
  • BulkSynchronize

Entity Framework Plus

开源免费:https://github.com/zzzprojects/EntityFramework-Plus

Website: http://entityframework-plus.net/

Free & Open source library that support following features:

  • Audit
  • Batch Operations
    • Batch Delete
    • Batch Update
  • Query
    • Query Cache
    • Query Deferred
    • Query Filter
    • Query Future
    • Query IncludeFilter
    • Query IncludeOptimized

EFUtilities

1.功能包含单属性更新. 
2.Delete by query 
3.Batch insert entities 
4.Batch update entities 
5.Partial updates / Not loading the data from DB first 
6.Update by query 

如何使用看项目官网 
https://github.com/MikaelEliasson/EntityFramework.Utilities

代码获取方式如下:

支持EF4和5 
https://www.nuget.org/packages/EFUtilities/0.1.0

PM> Install-Package EFUtilities -Version 0.1. 

支持EF6 
https://www.nuget.org/packages/EFUtilities

PM> Install-Package EFUtilities 

EntityFramework.Extended

主要功能:批量更新和删除,缓存

//    Deleting

//delete all users where FirstName matches
context.Users
.Where(u => u.FirstName == "firstname")
.Delete(); // Update //update all tasks with status of 1 to status of 2
context.Tasks
.Where(t => t.StatusId == )
.Update(t => new Task { StatusId = }); //example of using an IQueryable as the filter for the update
var users = context.Users.Where(u => u.FirstName == "firstname");
context.Users.Update(users, u => new User {FirstName = "newfirstname"});

2015年后停止更新。迁移到Entity Framework Plus

开源地址: https://github.com/loresoft/EntityFramework.Extended

PM> Install-Package EntityFramework.Extended

efbulkinsert

批量插入 ,已迁移到Entity Framework Extensions
http://efbulkinsert.codeplex.com/

EF4
PM> Install-Package EntityFramework.BulkInsert-ef4
https://www.nuget.org/packages/EntityFramework.BulkInsert-ef4 EF5
PM> Install-Package EntityFramework.BulkInsert-ef5
https://www.nuget.org/packages/EntityFramework.BulkInsert-ef5 EF6
PM> Install-Package EntityFramework.BulkInsert-ef6
https://www.nuget.org/packages/EntityFramework.BulkInsert-ef6

内容来自 :

https://blog.csdn.net/phker/article/details/49334287

EF学习推荐文章:你必须知道的EF知识和经验