value types & typed lists

Posts   
 
    
costab
User
Posts: 36
Joined: 21-Aug-2010
# Posted on: 31-May-2011 17:56:17   
  1. Is it possible to add a collection in a value type using the llblgen editor?

  2. Is it possible to specify the row type of a typed list as an existing value type class?

Thanks

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 31-May-2011 20:59:53   

1) Sorry, I'm not sure I understand what you mean - could you elaborate further please ?

2) Unfortunatly not, the row types of TypedList are always of the type [TypedListName]TypedListRow. What are you trying to acheive ? We may be able to suggest alternatives.

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 01-Jun-2011 11:45:49   

costab wrote:

  1. Is it possible to add a collection in a value type using the llblgen editor?

Valuetypes can't have relationships in llblgen pro. NHibernate supports entity types to be used as value types (or component types) but we do not. So: no you can't simple_smile

  1. Is it possible to specify the row type of a typed list as an existing value type class? Thanks

You can select fields from a valuetype in a typedlist, just add the entity with the valuetypes to the typed list, then select the field (s) you want to add. In a typed list, the valuetype fields are flattened, as the list is a flat list, so you can't have a column of type 'Address' if Address is a valuetype, all fields in 'Address' are selectable independently. This is done because the form in which the typedlist is generated isn't determined at this stage: a class or a datatable or whatever: it depends on the output template what the class form will be for the typedlist, and e.g. for a datatable having fields of type 'Address' won't work.

Frans Bouma | Lead developer LLBLGen Pro
costab
User
Posts: 36
Joined: 21-Aug-2010
# Posted on: 01-Jun-2011 17:52:57   

MTrinder wrote:

1) Sorry, I'm not sure I understand what you mean - could you elaborate further please ?

2) Unfortunatly not, the row types of TypedList are always of the type [TypedListName]TypedListRow. What are you trying to acheive ? We may be able to suggest alternatives.

Matt

1.

I basically want to define DTOs. Sometimes the pages I am developing display data that doesn't exactly match the entity classes, so I need DTOs.

For instance, I needed a DTO to hold data from a primary table and a Dictionary object with other DTOs (language specific).

My thought was that the value type classes can be used as DTOs but then I noticed that I cannot add a collection to a value type... Please read this link for more on the DTO pattern: http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html

  1. I am trying to re-use DTOs. Instead of having the tool generate all these ***TypedListRow classes I wanted to define my own DTO classes as the row types.

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Jun-2011 05:38:36   

Wouldn't be better to create (or modify existing ones) your own DTO templates that generate such classes?

What target framework and preset are you using?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 02-Jun-2011 10:46:51   

I agree, just create by hand the DTO classes you want and use them in the query as a projection result:

var q = from c in ctx.Customer where c.Country=="Netherlands" select new MyCustomerDTO() { ID = c.ID, CompanyName = c.CompanyName};

ValueTypes in LLBLGen Pro are the valuetypes as known in DDD (evans). DTOs are buckets for data transfer from point A to B, so why not use the entities generated for that (or a typedlist) and convert the data of the DTO in a model object for your MVC/MVVM setup?

Frans Bouma | Lead developer LLBLGen Pro