开发者

What is the neatest and most efficient way to implement property changed events with Entity Framework 4 with POCO support?

Seeing that the POCO template out-of-the-box does not include OnPropertyChanged support for simplicity, what would be the neatest [and most efficient] way to implement property changed events to my POCO objects 开发者_运维百科within Entity Framework 4, similar to the standard EF 4.0 Data Model which throws these events?

I really want something with high performance, I don't even mind what property has changed; I would be happy to just receive an event when the entity instance/object has any property that has changed.

My closest guess would be to implement a strategy like this into the POCO T4 Template (.tt) which generates my POCO classes, would I be on the right track? However I just want to make sure this is the most common approach? Is this already done as a standard POCO template somewhere?

More on EF 4.0 with POCO support: http://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx

Also standard EF 4.0 POCO Entity Generator Template I am using: http://visualstudiogallery.msdn.microsoft.com/23df0450-5677-4926-96cc-173d02752313?SRC=VSIDE


You actually answered your own question. The way to go is modifying T4 template and add level of support you need. If you need some inspiration check default classes generated by entity designer when not using T4 templates or classes generated by Self-tracking entities generator (another T4 template) - they should also use OnPropertyChanged.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜