Just use the adp. Net entity framework POCO templates to generate. Download the template.
Right click in the entity designer and select "add code generation item" and choose the poco template. Now your objects don't have all of the 'entity framework baggage' with them. Proxies are automatically created behind the scenes and you don't need to do any object mapping.
You can find this template by adding a new item to visual studio 2010, and searching the online templates from within the add dialog for POCO. The template name is: ADO. NET C# POCO Entity Generator.
From your comment I figured out I had messed up the frameworks and everything that's happening behind the scenes.. Now things are getting better.. – Stavros Mar 21 at 21:43.
You are looking for either AutoMapper or ValueInjecter. These two libraries are "Object to Object" mappers, which are designed for mapping values from one object to another object. I have only used AutoMapper before.It is great and pretty easy to pick up.
I've heard good things about ValueInjecter as well.
I thought there might be a problem in my design, because what I am facing here must be very trivial.. – Stavros Mar 21 at 15:41 @Strarvos - You can always do the left to right mapping code yourself. – jfar Mar 21 at 16:03 Yes, jfar is right - you can do it yourself. These tools accelerate that process.
– smartcaveman Mar 21 at 16:08 it's a design issue.. Maybe I should have posted more code... – Stavros Mar 21 at 17:20.
Use a ViewModel. This is a class that you declare having the properties you want to display on your View. For example: var country = TrendDB.Countries.
FirstOrDefault(c => c. CountryId == id); CountryDetails details = new CountryDetails(); details. FirstValueToShow = country.Name; return View(details); Remember to strongly type your Details view to the ViewModel.
As I was expecting, you don't actually need to do this, but it's a design issue – Stavros Mar 21 at 17:19.
After some investigation, I figured out that I had a design problem. Long story short, REMEMBER that in MVC 3 we need a to define the following class in the model public class StoryDBContext : DbContext { public DbSet Stories {get; set;} } And then in the controller THAT's the one to use when accessing the Entity Framework. In the previous version we were not defining the above class and were using the TrendEntities class (that was created by the framework) to access the DB.
That's a bit confusing... So, in my example, TrendDB should be of type StoryDBContext instead of TrendEntities and things are working as expected.
NO, it's not that :( – Stavros Mar 21 at 20:38.
Just use the adp.net entity framework POCO templates to generate. Download the template. Right click in the entity designer and select "add code generation item" and choose the poco template.
Now your objects don't have all of the 'entity framework baggage' with them. Proxies are automatically created behind the scenes and you don't need to do any object mapping. You can find this template by adding a new item to visual studio 2010, and searching the online templates from within the add dialog for POCO.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.