Massimiliano Peluso
Massimiliano Peluso

Reputation: 26727

How can I map the same property to differere columns on the same table

<property name="Registration" column="vrn" type="String" length="16" />
    <property name="Vin" column="vin" type="String" length="32" />
    <property name="EngineCapacity" column="engineCapacityCC" type="Int32" />
    <property name="Make" column="make" type="String" length="128" />
    <property name="ModelDescription" column="modelDescription" type="String" length="128" />
    <property name="ModelCode" column="modelCode" type="String" length="128" />**
    <property name="RegistrationDate" column="registrationDate" type="DateTime" />
    <property name="Manufacturer" column="manufacturer" type="String" length="128" />
    <property name="ManufactureDate" column="manufactureDate" type="DateTime" />
    <property name="Range" column="range" type="String" length="128" />**
    <property name="DriveType" column="driveType" type="String" length="1" />
    <property name="BodyType" column="bodyType" type="String" length="25" />
    <property name="EngineType" column="engineType" type="String" length="25" />
    <property name="Colour" column="colour" type="String" length="25" />
    <property name="IsImported" column="IsImported" type="Boolean" />
    <property name="IsLeftHandDrive" column="IsLeftHandDrive" type="Boolean" />
    <property name="Range" column="ClientRangeCode" type="String" />**
    <property name="ModelCode" column="ClientModelCode" type="String" />**
    <property name="IsTaxi" column="IsTaxi" type="Boolean" />

This mapping raise and exception (duplicate property ......)

I need to map ModelCode to both ClientModelCode and modelCode columns

I need to do the same for the property Range

thanks

Upvotes: 1

Views: 114

Answers (1)

Jamie Ide
Jamie Ide

Reputation: 49251

You can't. It's not possible, nor does it make sense, to have the same property name defined more than once in a class. Your class should have separate properties for ModelCode and ClientModelCode.

Another option is to have private members for ModelCode and ClientModelCode and expose just one through a public ModelCode property.

Upvotes: 3

Related Questions