Linq Expressions for creating objects
As you might know I am building my own Repositories for NHibernate as a part of my upcoming “glue” framework.
A part of that implementation are various transformers and default transformation strategies for things like tuple to object transformations (dto) and data reader to object transformations (dto)… the first is used when using projections, the later when calling stored procedures.
I’ve choosen to do this via Linq Expression Trees because I’ve been frankly scared to use the plain DynamicMethod till now, and as Expression trees do generate them in the background it seemed like a great way to do runtime code generation.
Probably in the future I will write some more detailed posts on the implementation itself and more on the reasons, but for starters here are a few links which will help to you give an insight into the power and how LINQ can be used waaaay beyond querying:
http://rogeralsing.com/2008/02/28/linq-expressions-creating-objects/
http://blogs.msdn.com/meek/archive/2008/04/25/using-linq-expressions-to-generate-dynamic-methods.aspx
http://blogs.msdn.com/meek/archive/2008/05/13/using-linq-expressions-to-generate-dynamic-methods-ii.aspx
Enjoy!

Leave a Reply