Dynamic DTO in .Net?
I have been doing quite a bit of work lately that involves taking stored procedure calls and mapping them to private DTO classes. I was thinking the other day there has to be an easier way. So far this is what i have come up with:
- CodeSmith - OK solution but it will be a no go where i work. The budget is pretty tight right now.
- Typed Dataset - Add columns to the dataset at runtime. While convenient i still don't like it. I've never been a fan of the overhead for a dataset.
- IronRuby / IronPython - Maybe read the return from the stored procedure at runtime and dynamically build an object in IronRuby or Python & return the object to VB.Net. I haven't investigated dynamic languages enough in .net to know how good of a solution this would be. I think c# has a little bit better of support with the dynamic keyword but know its not perfect. Where i work we have to use VB.Net and maybe that would make matters worse
- Dynamically build objects at runtime with Reflection.Emit--seems really really messy.
Is there a better solution that I'm not aware of? Maybe some open source project? I looked into Automapper but i believe that is just for mapping DTO<-->BusinessOb开发者_Python百科jects. Not really what I'm needing to do.Hopefully in the future we will be able to switch back and forth between dynamic / static languages fairly easily that will make problems like this simple
Did you consider using the Entity Framework?
http://msdn.microsoft.com/en-us/library/bb896279.aspx
精彩评论