配料DB在实体框架4.0命令实体、框架、命令、DB

由网友(戒不掉的烟、戒不掉的你)分享简介:我目前的项目需要与外部系统的日常同步。同步是基于其解析,并具有广泛的业务逻辑处理复杂的进口文件结构。由于业务逻辑,我们决定让这个在.NET code和再利用,而不是书面方式相同的逻辑在存储过程或集成服务现有的BL组成部分。 My current project requires everyday synchroniz...

我目前的项目需要与外部系统的日常同步。同步是基于其解析,并具有广泛的业务逻辑处理复杂的进口文件结构。由于业务逻辑,我们决定让这个在.NET code和再利用,而不是书面方式相同的逻辑在存储过程或集成服务现有的BL组成部分。

My current project requires everyday synchronization with external system. The synchronization is based on complex import file structure which is parsed and processed with extensive business logic. Due to the business logic we decided to make this in .NET code and reuse existing BL components instead of writting the same logic in stored procedures or integration services.

在BL层位于EF 4.0数据访问层的顶部。目前的实施过程中进口料,填充所有更改成的ObjectContext和交易执行的SaveChanges。当我检查SQL事件探查器我看到EF执行每个实体变化作为单个的SQL命令(有自己往返于DB)。此外,它看起来像这些命令完全顺序执行。所以,我有多达100.000往返数据库的初始导入之间10.000 - 50.000往返数据库为每日同步

The BL layer sits on top of EF 4.0 data access layer. Current implementation process the import batch, fills all changes into ObjectContext and executes SaveChanges in transaction. When I check SQL profiler I see that EF executes each entity change as single SQL command (with its own round trip to DB). Moreover it looks like these commands are executed fully sequentially. So I have up to 100.000 roundtrips to database for initial import and between 10.000 - 50.000 roundtrips to database for daily synchronization.

是否可以批量插入/更新/由EF本身或某些供应商/扩展莫名其妙地删除命令?

Is it possible to batch insert/update/delete commands somehow by EF itself or by some provider / extension?

推荐答案

没有,就不能这样做。(是的 - 我哭也)

No, it can't be done (yes - i weep also).

EF不支持批量操作,LINQ-SQL有(有)同样的问题。

EF does not support batch operations, LINQ-SQL had (has) the same problem.

您已经有了几个选择:

在存储过程 经典ADO.NET或EntitySQL 触发器

我已经在过去的选项1和3。

I've gone with option 1 and 3 in the past.

有三种方法的问题是你失去了EF抽象,内部图形(开放式并发),和你带回本地SQL的世界。

The problem with all three approaches is you lose the EF abstraction, the internal graph (optimistic concurrency), and your brought back to the world of native SQL.

阅读全文

相关推荐

最新文章