Fluent Nhibernate foreign key constraint -
i have problem fluent nhibernate mapping.
say have 2 entities b this:
public class { public virtual guid id { get; private set; } public virtual b reftob { get; set; } } public class b { public virtual guid id { get; private set; } }
how should map them, forbid me delete b when it's referenced a.
so, when i'm going say:
b b = new b(); a = new a(); a.reftob = b; session.save(b); session.save(a);
(...)
session.delete(b); //should throw kind of exception states //"cannot remove b used a"
first need figure out kind of relationship have. go link useful information on one-to-one relationship mapping - if want:
http://brunoreis.com/tech/fluent-nhibernate-hasone-how-implement-one-to-one-relationship/
Comments
Post a Comment