Rowan on Entity Framework Events and Alex’s Tips
I don’t post much on my blog lately (too busy working on Entity Framework for .NET 4!), but this post from my teammate Rowan struck me as something that would help lots of customers, so I wanted to link to it. It explains basically everything you need to know about events available in the Object Services API of Entity Framework.
While I am here, the tips series in my other teammate Alex James’ blog probably don’t need much publicity from me, but they are an awesome resource for customers.
Update 8.11.2010: Broken link to Rowan’s blog.
Comments
Anonymous
September 18, 2009
Will events be available to the EntityObject objects in version 4? Having "SavingChanges", for example, only in the ObjectContext class makes it hard to make a good OO design. I'd much rather have the EntityObjects manage events on their own.Anonymous
April 10, 2010
Mike, I am very sorry I never saw your comment until now. I usually rely on mail notification to manage comments and I never got yours. We did not add events to EntityObject in EFv4 and in general I would say there is a tendency to continue investing in POCO support and less on EntityObject. It is very likely that you will see support for nicer patterns to do things like validation or more granular control when entities are added, modified or deleted, and some of them might allow you to include code that handles events in your entities, but it is a little early to know how much of this is going to be included in the next release. In the meanwhile, you have SavingChanges, ObjectMaterialized, ObjectStateManagerChanged and also the virtual overload of SaveChanges. While it requires writting additional, you can use these mechanisms to build a layer abstraction that actually invokes methods in your entities for certain events. Hope this helps, Diego