Best Practices: When to use TypedViews vs Entities

Posts   
 
    
quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 09-Sep-2010 17:26:29   

After a year away from developing (again) I have another break from paid work so get to expore development again, and LLBL.

Yesterday I realized I had to take a step back and look at how I am approaching my application. My application like most has 3 basic forms for each entity. There is usually a List, Detail and Edit form and depending occasionally a batch form.

List * contains lots of rows * read only * limited fields or reduced fields * non-normalized

Detail * displays 1 complete record * read only * may have additional list grids - read only. * non-normalized

Edit * used for add and edit records * may edit 1 record at a time * may contain non-normalized data, but relies on normalized fields (like User_ID and Order_ID)

I am also using MVC and Data Annotations.

I am proposing that there should be a TypedList for the List and for the Detail and then use Entities (and possibly Units of Work) for the editing/add form. Even though the List and the detail are both non-normalized the quantity of fields shown in the list is quite often much less then the that shown in the detail. And when using Data Annotations you may specify different scaffolding (field visible or field non visible) for each.

What are the pro's con's to this approach, and suggestions to improve or refine it. Also out of curiosity is there a MVC example that does this?

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 10-Sep-2010 19:13:55   

Your approach is just fine. (nothing wrong with it). Whenever you need non normalized and read-only data, it's better to use a TypedList. Pros: Light, fast and flat for databinding.

Unfortunatly we don't have an MVC example yet.