The place where I work at has this function that inserts an object information into a database, it returns the ID that was created on insert but.., they have this function returning as a bool, whether it was able to commit or not the transaction. I want to be able to use the ID that it returns too but I am not sure how to access it, it is assigning it to the entity but the function returns a boolean.. so Its a bit confusing..
//HERE IT IS SAVING THE ID INTO THE ENTITY BUT I AM NOT SURE HOW TO ACCESS IT ?.
myentity.ObservationID = (System.Int32)_observationID;
myentity.AcceptChanges();
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(res);
In the submit button it is doing something like this
bool observationInserted = false;
observationInserted = observationAdmin.Insert(observationEntity);
if(observationInserted)
{
I need to grab the observation id that was saved, the code in the inserting function seems
to be doing this but it returns boolean, I need the ID and the boolean.
then it will navigate somewhere appending the id.
}
NoteL After the call of the insert in the submit button it goes to some kind of transaction validation manager and from there it then calls the insert function with the transaction result.
Your observationEntity will be updated with the unqiue ID.
You can get it by refering to the ID property:
observationEntity.ObservationID