C # access data as desired (2)

Source: Internet
Author: User

This morning, it was quite strange. First, the snow floated for a few minutes, almost at intervals. The snow stopped, and several hail were lost, and the brakes stopped, and then it squeezed out some rain,

I am still in a hurry ......

Now, let's get down to the truth. I learned how to create a record in the previous section. In this section, I will talk about how to operate a single record.

Before you operate a record, make a comparison between the modified record and the modified one.

Public bool isdirty
{
Get
{
Foreach (string key in originaldata. Keys)
{
If (originaldata [Key]! = Currentdata [Key])
{
Return true;
}
}
Return false;
}
}

Public bool isnew
{
Get
{
Return isnew;
}
}

Public bool isdeleted
{
Get
{
Return isdeleted;
}
}

 

For deleting a record, it will always be:

Public void Delete ()
{
Isdeleted = true;
}

When a new record is created, isnew = true; isdeleted = false.

At this point, we are ready together. The following is the method of the record class, which is also the focus of record operations.SubmitAndReturn Value:

 

Public void Acceptchanges ()
{
Originaldata = new dictionary <string, Object>
(Currentdata );
Isnew = false
;
}

Public voidRejectchanges ()
{
Currentdata = new dictionary <string, Object>
(Originaldata );
Isdeleted = false
;
}

It is easy to understand that if the user acceptchanges data, the new dataset (currentdata) will be used to overwrite the source dataset (originaldata );

Otherwise, no.

OK. Now we have finished creating and operating a single record. Isn't it very easy .......

With this foundation, you can create a record set and store the record set. The next section describes how to make a record set and

How to operate the record set -----

^ _ ^

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.