Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 251559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:36:17+00:00 2026-05-11T21:36:17+00:00

I have a class which is mirror of table. public class Patient { public

  • 0

I have a class which is mirror of table.

    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;
        }
    }

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)

    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");
        }
    }

If i get exception or false result, do you have any suggest to me about how can i handle it??

I want to use TRANSACTION (because i don’t want to set same row again.) but HOW?

Thanks in advice …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:36:17+00:00Added an answer on May 11, 2026 at 9:36 pm

    You could implement System.ComponentModel.IEditableObject interface and use that entity like this

      Patient pt = new Patient(12);
      pt.BeginEdit();
      pt.Name = args[0];
      pt.Address = args[1];
      if (WSCallIsOK())
         pt.EndEdit();       // save is OK
      else
         pt.CancelEdit();   // sets values back
    

    Example code only for property Sex

    // holds backup of values
    private string __Sex;
    private string _Sex;
    public string Sex
    {
        get
        {
            return _Sex;
        }
        set
        {
            bool changed = _Sex != value;
              if (changed)
                {
                    this.RaisePropertyChanged("Sex");
                }
    
        }
    }
    
    
    #region IEditableObject Members
    
    private bool _editing = false;
    
    public void BeginEdit()
    {
        if (!_editing)
        {
            // create copy of property
            __Sex = _Sex;
            //other properties here
            _editing = true;
        }
    }
    
    public void CancelEdit()
    {
        if (_editing)
        {
            // revert back
            _Sex = __Sex;
            //other properties here
            _editing = false;
    
        }
    }
    
    public void EndEdit()
    {
        if (_editing)
        {
            _editing = false;
        }
    }
    
    #endregion
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class which have one public method Start , one private method and
I have class Money which is an @Embeddable @Embeddable public class Money implements Serializable,
I have class Employee which is something like this. class Emp { int EmpID;
I have class Lazy which lazily evaluates an expression: public sealed class Lazy<T> {
I have class which sends requests to the webservice public class JSONParser { CookieStore
I have class(Customer) which holds more than 200 string variables as property. I'm using
I have a class which looks something like this: class MyClass { public: //
I have a class which has a string vector as a variable and a
I have class in which I am sorting a list. import java.util.*; public class
I have an class which contains the following properties: public class SomeClass() { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.