How-to question: modelling groups of columns as one class property

Posts   
 
    
mba
User
Posts: 10
Joined: 06-Apr-2006
# Posted on: 14-Sep-2010 05:19:23   

I don't know even what to search for in the forum for this.

Has anyone done this before, or how is it possible to create an entity class like this, mapped to one table:

the Customer class has a property HomeAddress which is itself a class of type AddressEntity The class AddressEntity has fields like AddressLine1, City, State, Zipcode etc...

The customer class also has a property WorkAddress which is itself the type AddressEntity also.

Customer's unique ID is called CustomerID, let's say, but the underlying database is written where all these fields are columns on the Customer table create table Customers ( CustomerID int not null identity(1,1), HomeAddressLine1 varchar(50) null, HomeAddressLine2 varchar(50) null, ... etc... WorkAddressLine1 varchar(50) null, etc... )

I am starting out with the (unchangeable-for-now) database, and want to create a model that is nice.

I also have the added challenge, that the Customer table in SQL has hard-coded limit of 25 addresses let's say. So, really, I would want the Customer class to have a property called Addresses, which is a strong-typed collection of AddressEntity types, each would have an identifying unique description (i.e. 'Home', 'Work', 'Work2', etc...)

??

thanks,

Mike

mba
User
Posts: 10
Joined: 06-Apr-2006
# Posted on: 14-Sep-2010 06:08:05   

one more thought... I am using Version 3 and am targeting the LLBLGen framework, not EF.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 14-Sep-2010 08:12:23   

So you want to refactor some fields in a value type. Sorry, not possible for your target framework. You will have to see if you can normalize your database.

You also could a custom Address class at your generated generic code, then mae a property of type Address in your Entity. In ther you can translate the address class to set the fields, and veceversa.

David Elizondo | LLBLGen Support Team