没有更多SavingChanges事件 [英] No more SavingChanges event

查看:86
本文介绍了没有更多SavingChanges事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CTP5并想知道savechanges事件在哪里?是否会成为DbContext的一部分或覆盖SaveChanges是RTM的全部内容?


Zeeshan Hirani Entity Framework 4.0 Recipes by Apress


http://weblogs.asp.net/zeeshanhirani

Using CTP5 and was wondering where the savingchanges event was? Is it going to be part of DbContext or overriding SaveChanges is all we are getting for RTM?


Zeeshan Hirani Entity Framework 4.0 Recipes by Apress
http://weblogs.asp.net/zeeshanhirani

推荐答案

Hello Zeeshan ,

Hello Zeeshan,

您可以覆盖DbContext.SaveChanges或覆盖DbContext.ValidateEntity以通知正在保存的各个实体。默认情况下,ValidateEntity仅针对Added和Modified实体调用,因为大多数常见验证规则不会将
应用于要删除的实体。但是,您也可以通过重写DbContext.ShouldValidateEntity来自定义该行为。

You can either override DbContext.SaveChanges or override DbContext.ValidateEntity to be notified of individual entities being saved. By default ValidateEntity is only called for Added and Modified entities, because most common validation rules don't apply to entities being deleted. However, you can also customize that behavior by overriding DbContext.ShouldValidateEntity.

第三种方法是获取DbContext的基础ObjectContext并订阅其SavingChanges事件。

A third alternative is to obtain the underlying ObjectContext of the DbContext and subscribe to its SavingChanges event.

希望这会有所帮助,

Diego

Hope this helps,
Diego


这篇关于没有更多SavingChanges事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆