How do I create a dynamic data transfer object dynamically from ADO.net model
Posted
by
Richard
on Stack Overflow
See other posts from Stack Overflow
or by Richard
Published on 2011-02-15T05:02:35Z
Indexed on
2011/02/15
7:25 UTC
Read the original article
Hit count: 294
I have a pretty simple database with 5 tables, PK's and relationships setup, etc. I also have an ASP.net MVC3 project I'm using to create simple web services to feed JSON/XML to a mobile app using post/get. To access my data I'm using an ADO.net entity model class to handle generation of the entities, etc.
Due to issues with serialization/circular references created by the auto-generated relations from ADO.net entity model, I've been forced to create "Data transfer objects" to strip out the relations and data that doesn't need to be transferred.
Question 1: is there an easier way to create DTOs using the entity framework itself? IE, specify only the entity properties I want to convert to Jsonresults? I don't wish to use any 3rd party frameworks if I can help it.
Question 2: A side question for Entity Framework, say I create an ADO.net entity model in one project within a solution. Because that model relies on the connection to the database specified in project A, can project B somehow use that model with a similar connection? Both projects are in the same solution.
Thanks!
© Stack Overflow or respective owner