Interested in POCO LINQ?
I've been investigating using LINQ to SQL with a POCO approach. (POCO = Plain Old CLR Objects.) My ideal solution would be something like this:
I want a solution that supports all four goals outlined above. [Update: here it is]
Question: If I can find one, would you be interested in it?
If enough people say yes (either in comments below or via email), I’ll try to post something within the next few weeks.
I understand that knowledgable people have said this can't be done. I respectfully disagree ;-) Based on work so far, I’m satisfied that it can be done.
Update: The idea would be that you'd hand-write .NET classes, according to a few simple conventions. Do that and you'd automatically get working bidirectional relationships and lazy loading, plus automatic runtime generation of the correct mappings. (You'd never use SQL Metal or the Visual LINQ designer.)
You could also generate the database if you want. (I.e. the usual model is generate-code-from-database; this would allow (but not require) generate-database-from-code). If you use TDD, you could create and test the objects using TDD (running in-memory tests) and then generate the database.
Other simple little benefits would be: e.g. could have one file per class (which you can't with MS's generators); could put comments on the properties of those classes (which you can't with MS's generators, as far as I can tell), could put your own attributes on the entity/domain object classes, e.g. for attribute-based validation frameworks (again, you can't with MS's generators), entity classes compact enough to actually read them ;-)
Footnote: In this post I’m talking specifically about LINQ to SQL. I know that there are (or soon will be) several fine independent ORMs that use the LINQ language features to create their queries, but execute those queries with their own backend. A number of these products support POCOs but, for my current project, I need a solution for the full Microsoft "stack" - including LINQ to SQL.
- Entity classes are simple enough to be hand-written (no need to generate them with SQL Metal or VS 2008)
- Mapping is easy (no need to manually map every property via attributes or external XML)
- Lazy-loading works
- Bi-directional relationships work (update one end, and the other is synchronized automatically)
I want a solution that supports all four goals outlined above. [Update: here it is]
Question: If I can find one, would you be interested in it?
If enough people say yes (either in comments below or via email), I’ll try to post something within the next few weeks.
I understand that knowledgable people have said this can't be done. I respectfully disagree ;-) Based on work so far, I’m satisfied that it can be done.
Update: The idea would be that you'd hand-write .NET classes, according to a few simple conventions. Do that and you'd automatically get working bidirectional relationships and lazy loading, plus automatic runtime generation of the correct mappings. (You'd never use SQL Metal or the Visual LINQ designer.)
You could also generate the database if you want. (I.e. the usual model is generate-code-from-database; this would allow (but not require) generate-database-from-code). If you use TDD, you could create and test the objects using TDD (running in-memory tests) and then generate the database.
Other simple little benefits would be: e.g. could have one file per class (which you can't with MS's generators); could put comments on the properties of those classes (which you can't with MS's generators, as far as I can tell), could put your own attributes on the entity/domain object classes, e.g. for attribute-based validation frameworks (again, you can't with MS's generators), entity classes compact enough to actually read them ;-)
Footnote: In this post I’m talking specifically about LINQ to SQL. I know that there are (or soon will be) several fine independent ORMs that use the LINQ language features to create their queries, but execute those queries with their own backend. A number of these products support POCOs but, for my current project, I need a solution for the full Microsoft "stack" - including LINQ to SQL.