Note that there are some explanatory texts on larger screens.

plurals
  1. PORollBack or Commit (Enterprise Library Transaction) over classes when other class get result in C#
    text
    copied!<p>I have a class which is mirror of table.</p> <pre><code> public class Patient { public int Patient_id { get; set; } public string Name { get; set; } public string Address { get; set; } public bool Sex { get; set; } public Patient f_UpdatePatient(Patient _patient) { string QUpdate = " UPDATE Patients " + " SET Name = '" + _patient.Name + "'" + " ,Address = '" + _patient.Address + "'" + " ,Sex = " + (_patient.Sex ? "M" : "F") + " WHERE patient_id = " + _patient.Patient_id; Database db1 = DatabaseFactory.CreateDatabase("cnnStr"); DataSet ds = db1.ExecuteDataSet(CommandType.Text, QUpdate); // First, How can i set my instance which is coming as a parameter // to my real object. Without passing each value to eac prop of obj. return this = _patient; } } </code></pre> <p>I have another class which uses Patient. Before use it, it is setting new values to one instance of Patient class, thus i can send the last value to web service. (In fact i need to write db before i use web service which is not in my project)</p> <pre><code> public class ServiceConnection { public static void Main(string[] args) { Patient pt = new Patient(12); // Just want to show that i need DB update. pt.Name = args[0]; pt.Address = args[1]; try { // Now i am connection web service and sending pt instance bool isOk = f_SendToService(pt); } catch (Exception ex) { // Now, at this point, I WANT TO ROLLBACK MY UPDATE with TRANSACTION // or something else throw (ex); } } private static bool f_SendToService(Patient pt) { // trying to send. But sometimes, i get timeout errors // sometimes i get false result. throw new WebException("Sorry it couldn't reach to WS"); } } </code></pre> <p>If i get exception or false result, do you have any suggest to me about how can i handle it??</p> <p>I want to use TRANSACTION (because i don't want to set same row again.) but HOW?</p> <p>Thanks in advice ...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload