Effectively then, you're trying to change the type of an existing
object.  I don't know of way of doing that in NHibernate (nor in C# !).
See
http://stackoverflow.com/questions/478296/nhibernate-changing-sub-types
for a maybe useful discussion.

 

/Pete

 

From: [email protected] [mailto:[email protected]] On
Behalf Of Felipe Oriani
Sent: 18 July 2013 17:51
To: [email protected]
Subject: Re: [nhusers] Save a Child for a existent Parent

 

Hi Pete, 

 

As my exemplo code, I already have the Item object on the database and I
also have the Id to create a new ItemCommercial (that inherit from the
Item). I would like to save the ItemCommercial with the Id that I have
(Id of the Item). 

 

Thanks

 

On Thu, Jul 18, 2013 at 12:55 PM, Pete Appleton
<[email protected]> wrote:

Is that a Parent : Child relationship, or are you changing the type of
an existing entity - do you expect to have two rows with the same Id ?

 

/Pete

 

From: [email protected] [mailto:[email protected]] On
Behalf Of Felipe Oriani
Sent: 18 July 2013 16:26
To: [email protected]
Subject: [nhusers] Save a Child for a existent Parent

 

Hello guys, I have a model with some inherits and it is using nhibernate
to persisti on a Database. The nhibernate mapping with fluent nhibernate
is working fine, but I have a scenario where I need to save a child for
a existent parent. My model looks like this:

 
 
 
 
public class Item
{
 
 
   public long Id { get; set; }
   public string Name { get; set; }
   // other properties
}
 
 
 
public class ItemCommercial : Item
{
 
 
   public decimal Value { get; set; }
   // other properties
} 

In my Database, the respective tables are related by Id <-> Id (one per
one).

I would like to know, how to Save just a ItemCommercial instance for a
existent Item on database. I have the Id of the Item, but I do not know
howt to say to nhibernate to say just the Child, instead creating a new
Item, for sample:

 
 
 
 
session.Save(itemCommercialObj); 

Thank you.

 

-- 

______________________________________
Felipe B Oriani

felipeoriani.com.br <http://felipeoriani.com.br/>
[email protected]

-- 
You received this message because you are subscribed to the Google
Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

-- 
You received this message because you are subscribed to the Google
Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:nhusers%[email protected]> .
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.
 
 





 

-- 

______________________________________
Felipe B Oriani

felipeoriani.com.br <http://felipeoriani.com.br/>
[email protected]

-- 
You received this message because you are subscribed to the Google
Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to