Click here to Skip to main content
15,885,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings, my entity class looks like this:

C#
public class Foo 
{
   public virtual long ID { get; set; }
   public virtual string Name { get; set; }
   public virtual Foo2 Foo2 { get; set; }
}


And mapping for him:

C#
public class FooMap: ClassMap<Foo>
{
   public FooMap()
   {
      id(x=>x.ID);
      Map(x=>x.Name);
      
      References(x=>x.Foo2).Cascade.All;
   }
}



How can link it to the id, instead of an object?
Something like this:

C#
public class Foo 
{
   public virtual long ID { get; set; }
   public virtual string Name { get; set; }
   public virtual long Foo2ID { get; set; }
}



How can i achieve this?
Posted

1 solution

Just use Map(x=>x.Foo2ID) then, but then you lose the cascade related functionality. Using Map(x=>x.Foo2ID) you just tell NHibernate to map to that column as if it was just like any other column.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900