C # Linq them how to delete and bulk deletion

C # Linq them how to delete and bulk deletion

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

What is deleted?
Delete: refers to longer needed files deleted from the directory list system, in order to free up disk space for other operations. In the computer most of the "radical" is to delete it removed from the list, and other files can be overwritten. So please make sure mistakenly deleted once before, there is hope to recover! Information and data in a computer so stored as files, delete files divided into two cases, one called "tombstone" and the other called "physical delete."
Logical delete the name suggests, files are not really deleted, but is the first byte of the file name is changed to the operating system does not recognize the characters, this is usually the delete operation is reversible, that is to say with the appropriate tools or software can recover deleted files out.
Refers to physically remove the magnetic storage area used to store the files to be erased or real clear, so deleted files can not be recovered
deleted 2. C # how to achieve the data?
delStudent function (studentID) {
layer.confirm ( "piece of data you want to delete?", {icon: 3, title: " prompt"}, function () {
$ .post ( "delStuInfos", {StudentIds: studentID} , function (msg) {
layer.alert (msg, {icon: 0, title: "Tip"});
tabStudent.reload (); // refresh the table
});
});
deleted primary key, then delete it since it is student ID
plug layui among similar systems confirm, but far better than confirm, in addition confirm that it is not the same as blocking and systems you need to interact with the statements in the body of the callback. Similarly, its parameters are automatically filled in.
Asked the prompt box (four parameters content options yes cancel canceled)
function is actually a single block of code, you can call it at any time. All functions must be added at the beginning of "function ()" to the function name: Named the best way is to have the name of the function and performance of its functions consistent. function () function syntax: function function name (parameter 1 [Parameter 2]) {function body return Return Value} with a method name (Custom / self-named) after the function name and then later transfer parameters; longer post Submit post is transferring data to the server
to delete a single data, student information to be deleted according to StudentID query how to delete a single student table information
PW_Student dbStudent = (from tbStudent in myModels.PW_Student
the WHERE tbStudent.studentID == StudentID
the SELECT tbStudent) .Single () ;
the Count () is a query more than a few
tolist () is the number of converted List
single () query certain data requires the use of a single try catch catch the exception
myModels.PW_Student.Remove (dbStudent); delete the core code
then you need consider deleting get deleted if it is associated with other tables candidates UserID
var userId = dbStudent.UserID;
schedule information based on userId query you want to delete user roles
DbUserRoleDetail = PW_UserRoleDetail (from tbUserRoleDetail in myModels.PW_UserRoleDetail
WHERE == tbUserRoleDetail.UserID the userId
SELECT tbUserRoleDetail) .Single ();
myModels.PW_UserRoleDetail.Remove (dbUserRoleDetail);
myModels.SaveChanges (); at least one
so new and updated with respect to He said the amount of code to delete is relatively small, but whether it is a page or controller in addition to bulk delete delete it as well!
The acquisition of id, the best in the array defined foreground, the background is so passing a comma-separated string, which can eliminate spaces. Compared to the background and then remove it after the incoming space in the middle, the simple number. Of course, it can also eliminate space after passing the background. For example, a string passed in the background. Can .split ( ","); removing the space method, and a comma as a delimiter, an array is obtained. Then delete operation through the array
to obtain data var checkStatus = layuiTAble .checkStatus ( "ID ") for the selected row;
Note : checkStatus layui is a plug-in method, a direct call;
2. Analyzing its length eg returned: if (checkStatus. data.length> 0)
3. declare variables, if the string var studentIds = ""; an empty string
4. traversal cycle for loop for (var i = 0; i < length if the inside; i ++) {
+ = checkStatus.data studentIds [I] .studentID + ";";
// + = is the string concatenation operator javaScript basic assignment is equivalent to x + = y x = x + y // use Split (;) divided}
5.studentIds studentIds.substring = (0,. 1-studentIds.length);
// remove the last ";"
Note: Substring () method for extracting an intermediate character string interposed between two specified index; returned string including the character at the start, but does not include a stop characters; [0, studentIds, length- 1) first after closing the opening section
6. the refresh callback table
bulk delete part of the controller:
1. Note that pass over the int type or string type (division StudentIds)
number of data strings and affirm two pieces 2. record deletion success / failure
/ / delete record number of stripes success / failure
3. judged pass over the string is empty of spliced id split
traversal cycle of
 mass delete is based on the deletion of, first, a single data, according to a check later check the box to get the data and then based on selected data and then determine whether further divided according to the last symbol; so that although the amount of code a bit more but in the face of big data to be deleted is to solve the big problem saving a lot of time

Guess you like

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