.net - Npgsql Command with Multiple Statements -


in npgsql v2, use following code update record, , return updated record values using single npgsql command.

the command.commandtext property contains both update statement , select statement. idea being when command.executereader called both commands run, results select command returned (since last command).

after upgrading npgsql version 3.0.3.0 value in datareader (from select statement) still original value, , not updated 1 (the return dr("action") line in code). have tried every different isolationlevel , give same results (as though select statement not seeing updated value insert statement). value updated in database (if re-query record has updated value).

i can split , use 2 separate npgsqlcommand (one insert, , second select), don't want create second round-trip server.

this simplified function, purpose of real function update record on db server, , update object in application other fields server updated (such "last_updated" timestamp field updated on server each time record updated).

is there way make work npgsql v3.0.3.0?

public function updaterecordexample(id guid, newaction string) string         using conn new npgsqlconnection("connection string here")             using trans = conn.begintransaction(isolationlevel.readuncommitted)                 dim command = conn.createcommand                 command.updatedrowsource = updaterowsource.firstreturnedrecord                 command.commandtext = "update pm.action_item set action=@action id=@id; select * pm.action_item id=@id;"                 command.parameters.add(new npgsqlparameter("id", id))                 command.parameters.add(new npgsqlparameter("action", newaction))                 using dr = command.executereader                     if dr.read                         return dr("action") 'this still original value , not "newaction"                     else                         throw new dbconcurrencyexception                     end if                 end using             end using         end using     end function 

note issue resolved in npgsql 3.1.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -