I’ve recently been reviewing the code for my Entity Framework (simple O/R Mapping, Entity validation, etc) to determine if I should consider swapping out the O/R Mapping for something else such as NHibernate, NPersist, Wilson OR Mapper, etc. The reason I’ve been considering this is that swapping out the O/R Mapping functionality within my Entity Framework with one of the more widely used frameworks may make it easier for people to extend ActiveType (CMS) for their unique needs.
As part of my review I was investigating the differences in functionality between the other O/R Mappers out there and the lightweight O/R mapper I’ve developed in my base Entity Framework. There are a lot of obvious differences, but, as you might be able to tell from the title of this post I’m going to focus on how the mapping is configured in the various O/R Mappers. Most O/R Mapping products out there today have the mapping of objects to database tables defined in an external configuration file. There are some (mine included) that define the mapping within the classes themselves via custom attributes.
I’ve recently been reading up on Indigo and as I’ve worked through all the code samples I couldn’t help but notice their extensive use of attributes. Although O/R Mapping and Indigo are clearly not one in the same I can’t help but notice the obvious similarities. I can’t help but think there are others that agree:
One last point, [DataContract] is just not an "Indigo" feature -- it is a feature for the entire .Net Framework.
Thinking about it in only Web services terms doesn't do justice to the host of important scenarios that it addresses elsewhere (version-tolerate persistence for any CLR type in any store).
We are defining a common abstract data model for CLR types for N scenarios -- many of which are Web service related.
http://www.douglasp.com/PermaLink.aspx?guid=01095547-b7f1-4e1d-8c4e-31038296f164
If [DataContract] is not just an Indigo feature but a feature for the entire .NET Framework then why couldn’t it become the center point for an O/R Mapping engine? And if attributes are good enough for defining [ServiceContract], [OperationContract], and [DataContract] why couldn't it also be good enough for defining details to be used by a persistence engine?