TypedView vs Entity

Posts   
 
    
JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 11-May-2013 20:46:48   

I'm using LLBLGen 4.0 Self Servicing and SQL Server 2012.

When I create a view in the database and want to use it, I can reverse engeneer the view to either an entity or a typed view.

What are the pro's an cons?

Regards,

Jan

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-May-2013 06:53:00   
  • The main difference is that a TypedView is read-only, while an Entity is not. If you have an editable view (f.i. a db view that query just one table, and it includes the PK) maybe you want to make changes at code. If that is the case maybe you want to map it as an Entity.

  • A TypedView cannot have model-only relationships, thus cannot have PrefetchPaths. It might be that you want that. Lets say you have a special view SpecialSalesByProduct that you want to use along with your Product entity. You could map it as an Entity and create a model-only relationship with the Product Entity. Then you will have a Product.SpecialSales navigator that you can fill with a prefetchPath.

Normally you don't have to map a DB view to an entity, as views are normally intended just for displaying info.

David Elizondo | LLBLGen Support Team
JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 01-Jan-2014 15:00:19   

What would be a proper way to use custom properties with a typed view. E.q. if the view contains 2 fields. If filled, you want to show field 1, else field 2.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Jan-2014 00:54:32   

Whether this is a TypedView or an Entity, you can create a custom property (better in a partial class/file), and display data from any of the fields based on whatever condition. Then use this property in dataBinding.