Why are you using a composite key with a identity column? That doesn't make
any sense. A database identity column will always create a unique key so no
composite key is required.

If you have created such a primary key in the database (which I did not know
was even possible). Then just ignore this fact. Use the identity column
(NUMBER) for your Id and just use a read-only many-to-one mapping for
CLIENTID.

--
Ramon

On Tue, May 17, 2011 at 10:27 AM, Rajeev <[email protected]> wrote:

>         Hello,
>
>       Am working on the mapping Composite Keys(NUMBER+ CLIENTID) for
> Table , Here both these keys are primary Keys and NUMBER field is
> autogenerated and set as Identity in Database. am facing a  problem
> for mapping these fields as composite keys.
>
> Error : "a different object with the same identifier value was already
> associated with the session"..---> this is becoz in Database this
> column is already set as Identity Column ..
>
> Please refer the below code
>
> public cliPendingBankruptcyMap()
>        {
>            Table("cliPendingBankruptcy");
>            LazyLoad();
>            CompositeId()
>               .KeyReference(x => x.usrClient, "CLIENTID")
>               .KeyProperty(x => x.NUMBER, "NUMBER");// HOW TO SET
> THIS FIELD AS IDENTITY.
>            Map(x => x.NAME).Column("NAME");
>            Map(x => x.CASENO).Column("CASENO");
>            Map(x => x.DATE).Column("DATE");
>            Map(x => x.DISTRICT).Column("DISTRICT");
>            Map(x => x.RELATION).Column("RELATION");
>            Map(x => x.JUDGE).Column("JUDGE");
>        }
>
> How can we set the Identity property  for NUMBER field in the above
> CompositeId()?? , So what approach should we need to follow for
> mapping the NUMBER field as Identity in  the above code.
>
> Your thoughts?
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>


-- 
Ramon

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to