table to object converter

  • Thread starter Thread starter abentov
  • Start date Start date
A

abentov

Hi,

I have a sample class – let’s say Person.

It has the following fields:

Id:int
Name:string
Address:string

I would like to reuse this class over different projects. In all of them I
need to bee able to store and retrieve the Person’s fields into/from a Data
Base.

All Data Bases’ “Person” Tables would have the same field types but different
field names. Example:

DB1>tblLondonCitizen:

londonCitizenID:int
londonCitizenName:string
londonCitizenAddress:string

DB2>tblHuman:

humanID:int
humanAddress:string
humanName:string

My idea is as follows:
Use a typed “Person” DataTable for each project and then build a “dbToPerson”
converter class. It should be able to receive a typed “Person” DataTable and
return a Person object collection; or receive a Person Object collection and
return a typed “Person” DataTable.

What bothers me a little here is that I should copy and do small changes to
this “dbToPerson” converter class for each project.

I would be glad to get feedback for an alternative way or improvements on
this one,

Thanks in advance,
Albert

--
Albert Benatov
Skype: abentov
http://albertbenatov.com

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-csharp/200606/1
 
Hi,

There are plenty of tools around that help you do this. If you look in the
archives you will find recommendations for several of those.
 
Back
Top