C # Linq how to modify them

C # Linq how to modify them

文献种类:专题技术文献;
开发工具与关键技术:VS
作者:蛋蛋

What is C # modify them?
Binding data by modifying the data, "Entity Framework" provides a bidirectional communication channel with the database. As already described how to use "Entity Framework" Get Data, and now look at how to modify the access to information, and send the changes back to the database
when updating an existing data using an Object object to obtain data, according to the object data created in the application's memory cache. To change the value of the object cache, the way to take and modify the value of any ordinary object, like - setting their properties.
How to modify? What circumstances modify them will happen?
Update of a conflict update operation may fail for a variety of reasons, the most common reason is that conflict. Two users try to update the same data, collision occurs. Carefully think about the consequences of using the "Entity Framework" in the application, you will find that there are many places are likely to conflict. Object data is acquired through a target, these data are cached memory application. At the same time, another user execute the same query, and get the same data. If two people have modified the data, and all the SaveChanges method is called, then in the database, a person will overwrite another person's changes. Otherwise reported abnormal;
Amendment should backfill
First need paged mode frame, and allowed to have the option to modify the conditions, the data in accordance with a further method of function name function backfill conditions, mode Click the Edit button to open the box,
function saveYuanGongUpdate () {
$ ( "# formUpdateYuanGong") [ 0] .reset ()
// form name form ID;
[0] .reset () to clear the form reset form or
$ ( "# formUpdateYuanGong") resetForm ();. is also reset the form
$ ( "# modalUpdateEmployee" ) .modal ( "show");
// entire modal box ID "show" is the English meaning of the show is the show, presented
here will need to write a post submission method is get to get data from the server, the server is post transferring data. GET URL is added to the parameter data queue to submit the form referred to in the ACTION attribute, and the value of the respective fields correspond form, it can be seen in the URL. post through HTTP post mechanism to various fields with its contents is placed in a form HTML HEADER URL address transmitted with the ACTION attribute refers. Users do not see this process. get security is very low, post high security. But the efficiency of the Post method than good. Security get way than the Post the way to badly, contain confidential information, the proposal submission by Post data; 2, when doing data query, recommended Get way; but in doing data added, modified or deleted, it is proposed Post manner;
so how data backfill it?
.post $ ( "selectEmployeeById",
{the EmployeeID: the EmployeeID
},
Here is a key-value pair, the key-value pair is to the left of the right parameter argument, parameter passing the left side of the controller with consistent F12 right is transferred may be affirmed defined
if the drop-down box mode data block field which need to backfill How to do it?
There is a packaging method can be called directly, and then backfilling the data based on the ID, name, but the name is inconsistent methods can be called createSelect we can see one of the first ID, the second data path url, third value below the value of his directly in front of the splicing help ID value "#" # so among writable ID value may not write
Here Insert Picture Description
// data Jquery encapsulation method of backfilling backfill loadDatatoForm form, but if the field is a direct backfill as many cumbersome loadDatatoForm ( "formUpdateYuanGong", EmpData); Here Insert Picture Description
then is post submission method name next step is to pass the reference here is mainly filled with data it is based on the master key is not equal to the judgment, this is a single data single; then the exception is needed to capture Try catch
runs often encounter some exceptions do division when the divisor is 0; enter a negative number when the user enters the age; when using the new operator to dynamically allocate space, leading to lack of space can not be allocated; accessing array elements, subscript out of range; when you open the file read, file there is no
dimension Furthermore, the abnormal scattered throughout the processing is not conducive code Protection, especially for the same abnormalities that occur in different places, have to write the same handling code is an unnecessary duplication and redundancy. If we can make an exception occurs in a variety of programs are executed in the same place, this place can focus on the abnormality, the program will be easier to write and maintain.
In fact, save the changes to save the changes to the previous save almost new but similar basic statements about the need to exclude the existence of the same data
Here Insert Picture Description
fields in each of the modal box which data need to determine whether whether the existing database and data among repeat, if you are prompted to repeat else {returnJson.State = false;
returnJson.Text = "employee information database that already exists, no need to repeat entry!";
}
text here is written in the page among the controller determines consistent time after the page is determined in the controller again determines ensure Finally, save the changes abnormal data

Guess you like

Origin blog.csdn.net/qq_42577408/article/details/89883445