I use the first approach of EF 4.1 Database First, while the T4 template generates my POCO classes in a separate assembly. I have repositories for receiving data and the level of service that is used to communicate with the user interface.
I tried to create cascading dropdowns. I am new to MVC and EF 4.1, so I was looking for stackoverflow for possible solutions.
This is an example viewmodel class:
public class MyViewModel { public int CustomerId { get; set; } public string CustomerName { get; set; } public IEnumerable<Phone> Phones { get; set; } }
What I have read so far, solutions:
Use ScriptIgnoreAttribute in System.Web.Script.Serialization on ScriptIgnoreAttribute properties - I don't really want to do this because I don't want to add a link to System.Web in my POCO project
Disable lazy loading in EF 4.1 DbContext - I'm not sure I want to use Include to complete my project
Returning anonymous types - will I have problems with this approach when my project gets big?
Use the ViewModel - suppose I have a Client that can have 1 or more phones. In the first drop-down list you can select "Customer", and in the second drop-down menu you will see all your phones.
But won't this create a circular exception on my Phones facility? Or would I make a special class for my Phone object? This seems like a lot of unnecessary code.
Use AutoMapper - no experience with AutoMapper, so I don’t know how complicated it is.
What would you vote for and why?
source share