How to update an object with nhibernate + fluent nhibernate? -


i query through nhibernate record database.

var result  = session.query<tablea>().where(x => x.id == 10).firstordefault(); result.where = "hi"; session.update(result) session.commit(); 

so result , update property , try update , commit it. crash because have forigen key table b(table can has 1 table b , table b has many table a's)

so reference cannot null. when tries update crashes.

so have

       var result  = session.query<tablea>().where(x => x.id == 10).firstordefault();         result.where = "hi";         result.tableb = session.load<tableb>(1);         session.update(result)     session.commit(); 

then happy.

how can update without having load tableb in?

set update value of tableb property mapping false. i'm not sure how you'd using fluent nhibernate, looks setattribute method you.

something along lines of: .setattribute("update", "false");


Comments

Popular posts from this blog

razor - Is this a bug in WebMatrix PageData? -

c# - How to set Z index when using WPF DrawingContext? -

visual c++ - Using relative values in array sorting ( asm ) -