Home > front end >  Look up to add or delete data
Look up to add or delete data

Time:12-01

1, the data of the new, modify, delete, query
Data query:
Assume that there are four tables, table (S_Grad), class table (S_Class), students table (S_Student), member table (S_Member)
(1) single table query, query student ID for five students of information (a single data)
Linq statement: S_Student dbStudent=(from tabStudnet in S_Student
Where tabStudent. StudentID==5
The select tabStuendt). Single ();
Lambda expressions: S_Student dbStudent=S_Student. Single (o=& gt; Grown tudentID==5);
(2) the multi-table query, query student ID for 5 students in class's and grade's class information (a single data)
Linq statement: S_Class dbClass=(from tabStudent in S_Student
The join tabClass S_Class in
On tabStudent. StudentID equals tabClass. StudentID
Where tabStudent. StudentID==5
The select tabClass). Single ();
Multiple items (3) the query: query table with ID at the intermediate class 3 class (multiple data)
Linq statement: ListWhere tabClass. GradID==3
The select tabClass). ToList ();
Lambda expressions: List(4) the subquery: query grade grade table ID information for 7 grade, and the ID for all class 7, grade information
Need to use two external class (grade GradVo inheritance table, ClassVo inherited class table), as follows:
Public class GradVo: S_Grad
{
Public List ClassList {get; set; }//class
}
Public class ClassVo: S_Class
{
//no need to expand the field
}
Query:
Linq statement: S_Grad=(from tabGrad S_Grad in
Where tabGrad. GradID==7
Select new GradVo ()
{
//set of field...
//sub queries are as follows:
ClassList=(from tabClass S_Class in
Where tabClass. GradID==7
The select tabClass). ToList ()
}. Single ();
(5) left join query: ID query class is 2 of all the students' information, and member information, only is a member of the
Students have a member ID, need an external class (StudentVo inheritance students table)
Public class StudentVo: S_Student
{
Public string member {get; set; }//member
{
Query:
List StudentList=(from tabStudent S_Student in
The join tabMember S_Member in
On tabStudent. MemberID equals tabMember. MemberID
Into tabStudentA//temporary table
The from tabStudentB in tabStudentA. DefaultIfEmpty ()
Select new StudentVo ()
{
//set of field...
//use mark operation assignment
//assignment statement is too long, written in the following
}). ToList ();
//if the null value assignment to an empty string, if a value is the value of itself,
Assignment: menber=tabMember member==null? "" : tabmember member
//temporary table: tabStudentA, new table: tabStudentB, processing: DefaultIfEmpty ()
Left join query: based on the table on the left, if the left and the right is not, then the query results to the left of the
Values are the values on the right is empty, if the left, and right there, the query result is
Empty,
Note: some of the students in the above query is not a member, there is no member ID, then the connection member table query
The student data must be empty, but also need the data, so in order to avoid this situation, make the
By connection on the left of the query results first saved to a temporary table and to deal with temporary table (if order
Is empty, returns null), will be processed in the temporary table is assigned to a new table, then the new table query,
Empty sequence have returns null, so as not to affect the query results,

New data:
Front desk: (1) to get the data
(2) the data validation
(3) sends the request, submit the data
(4) set the callback (popup message, etc.)
Background: (1) receiving data
(2) the data validation
(3) data (if required) according to actual condition rechecking
(4) new data
5. Save the new to the database
6. Return success message

Data change:
Backfill data:
Front desk: (1) sends the request (send a can determine the parameters of data, for example: ID)
(2) set the callback (backfill data)
Background: (1) according to the data query page parameters passed out the corresponding
(2) return the data
Modify data:
Front desk: (1) sends the request (send a can determine the parameters of data, for example: ID)
(2) set the callback (popup message, etc.)
Background: (1) receiving data
(2) the data validation
(3) data (if required) according to actual condition rechecking
(4) modify data
5. Save the changes to the database
6. Return success message

Delete data:
Front desk: (1) sends the request (send a can determine the parameters of data, for example: ID)
(2) set the callback (popup message, etc.)
Background: (1) according to the query page parameters passed out of the need to delete the data
(2) query the database, judge whether the data is being used, if the data is in use, can't delete the
The data
(3) delete data
(4)
save delete to the database(5) return success message
  • Related