c# - How to copy objects between sessions in NHibernate -


i copy entities mysql database brand new sqlite database (export). have code below:

ienumerable<foo> foolist; using (var sf = createmysqlsessionfactory("user", "password")) using (var source = sf.opensession()) using (var sf2 = class1.createsqlitesessionfactory(outputpath)) using (var dest = sf2.opensession()) {      foolist = source.query<foo>();      foreach (var foo in foolist)      {          dest.saveorupdate(foo);      }      dest.flush(); } 

both session factories created without problems. unfortunately saveorupdate throws lazyinitializationexception message:

illegally attempted associate proxy 2 open sessions

i understand both sessions open, couldn't find neat solution. ones find deep-cloning each foo, cumbersome (foo has properties of bar objects, have properties of boo objects etc.).

how can perform such bulk copy using nhibernate? please mind schema of source , destination databases not same. used different mappings achieve that.

have tried detaching foo session using:

source.evict(foo) 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -