views:

11

answers:

0

Hi All,

I have a situation where i have defined an entity in my domain model in which I would like to expose a single id column.

public class OfferedProduct  
{  
    public virtual string Id {get; set;}  

    //other properties
}

The legacy database table this will map to is

CREATE TABLE ProductGrouping  
MemberNumber INT NOT NULL,
GroupId CHAR NOT NULL,
...

I dont want to compromise the domain model by introducing two properties and mapping them using the "CompositeId" construct.

CompositeId().KeyProperty(x => x.MemberNumber).KeyProperty(x => x.GroupId)

What I want ideally is to concatenate the two values in the form {MemberNumber}{GroupId} and expose this as the Id value. I would then use a Custom Type to handle how these values are concatenated when retrieved from the DB and broken apart when saving/selecting.

I have noticed that the "CompositeId" method does not allow a customType as with the standard "Id" call; but the "Id" method does not provide the ability to set multiple columns. I have seen examples where people have used "Map" to combine two columns using a custom type, but not for id values.

I have noticed the "CompositeId" has an overload that can take a custom identity class but I am unsure how to use it in this scenario.

 CompositeId<OfferedProductIdentifier>(x => x.?)

Any help would be greatly appreciated.

related questions