c# - Nhibernate subsequent read after stored procedure call -


i have strange behaviour of nhibernate , ado.net. i'm using nhibernate standard orm operation faster ado.net (like batch or calling stored procedure).

so i'm doing following

var item = _items.getbyid(100); 

then call stored procedure update same entity following instructions

 var session = _sessionmanager.opensession();  using (var tx = session.begintransaction())  {       var item = _items.getall().firstordefault(x => x.itemcode == code);        var cmd = session.connection.createcommand();       session.transaction.enlist(cmd);       cmd.commandtype = commandtype.storedprocedure;        sqlparameter id = sqlutil.getparam("@bigid", sqldbtype.bigint, inout: false);        cmd.commandtext = "storedupdateitem";       cmd.parameters.add(sqlutil.getparam("@tstts", sqldbtype.timestamp, inout: false));       cmd.parameters.add(id);        int ret = cmd.executenonquery();       if (ret != 1)       {           throw new applicationexception("something gone wrong update");       }        tx.commit();        return _items.getbyid(id.value); } 

so last operation retrieve again using nhibernate repository patter item. problem item not update database. seems previous version. idea?

you can force nhibernate refresh cached version of item using refresh method of session object:

      ...       var item = _items.getbyid(id.value);       session.refresh(item);       return item; } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -