Home > Back-end >  Add modify delete query Java vs c #
Add modify delete query Java vs c #

Time:12-01

Query 1
LINQ: Integrated Query Language (English: Language Integrated Query, abbreviation: LINQ), pronunciation "link", is a Microsoft technology, SQL syntax to add a natural queries..net Framework of programming languages, the current can support c # and Visual Basic. NET Language
(1) the linq single (multi -) table query spelled
(from the custom table name in the Model object. The query table
Where the custom of the table name. Value field 1 relational operator
& & Customize the table name. Field value 2 relational operator
Orderby custom table name. Field
Select a custom table name
Select new: [attribute name=1] custom table name. Field 1
[the attribute name=2] custom table name. Field 2
[the attribute name=3] custom table name. Field 3
Select the name of the class: [attributes of a class 1=] custom table name. Field 1
[attributes of a class 2=] custom table name. Field 2
Single ();//query a single data, when there is no data or have multiple data triggered when abnormal
SingleOrDefault ();//query a single data, when no data is returned to the default value object (the default value is null); When there are multiple data trigger abnormal
ToList ();//query multiple data and converted to a List
The Count (); How many//query data
The complete code templates:
(1) query a single data, when there is no data or have multiple data triggered when abnormal
String oldPicture=(from tabUser in myModel. S_User
Where tabUser. UserID==user. UserID
The select tabUser. Picture). Single ();
(2) query multiple data and into the List, according to the same data between table and table ID even table query
List UserModules=(from tabModule in myModel. S_Module
The join tabP in myModel. S_Permission
On tabModule. ModuleID equals tabP. ModuleID
The join tabUseType in myModel. S_UserType
On tabP. UserTypeID equals tabUseType. UserTypeID
Oin tabUser in myModel. S_User
N tabUseType. UserTypeID equals tabUser. UserTypeID
Where tabUser. UserID==intUserID
Select new ModuleVo
{
ModuleID=tabModule moduleID,
ModuleName=tabModule moduleName,
ModuleDescrible=tabModule moduleDescrible,
ModuleFarID=tabModule moduleFarID,
BlFun=tabModule blFun,
ParentModule=(from tabModuleF in myModel. S_Module
Where tabModuleF. ModuleID==tabModule. ModuleFarID
The select tabModuleF). FirstOrDefault ()
}). ToList ();
(3) how many query data/query data to the total number of article
Int intTotalRow=listUser. The Count ();
(4) query the current condition of data, data query a single
S_User dbUser=myModel) S_User) SingleOrDefault (o=& gt; O.u serID==userID);
2 path
(1) the relative and absolute path
Description: about path
/root directory (the root directory of the Web server)
./the current directory,
./parent directory,
~/root directory the root directory (Application)
@ Url. Content (" ");
Converts the virtual path (relative) to the absolute path to the application
1. Modify the img element of the SRC splicing parameter t role is to make each request a different path, avoid the browser cache
The complete code templates:
$(" # validCodeImage "). Prop (" SRC ", "@ Url. Content (" ~/Main/CreateValidCode? T=") "+ new Date (). The getTime ());
(2) control statements
Control statement is used to control the process of the program, in order to realize the application of various structures, including:
If ()... The else... (conditional statements)
The switch (multi branch select statement)
For ()... (loop)
The do... While () (loop)
While ()... (loop) to reach end
Terminate the switch or break and loop statement)
The continue (end of the loop statement
Goto (unconditional to statements)
Return (return from the function statement)


3 new and modified
New and modified have a belong to their modal form, in a new modal dialog form is when you add the style of the modal dialog, in the view page to write new code to write new button click event? To reset the form? A new url (path)? The title of the new modal form? Open the modal and disable the esc exit and not to close dynamic modal dialog when click on the background? Save the new? The inside of the form (define a variable to gain value)? Judgment can't be empty string otherwise will alert users to complete? Open load layer? Close the load layer? Refresh the form? Close the modal dialog
First of all we write in the HTML code for two modal dialog form code, a new, a modified, they two operations are need pop-up modal form

Feature: the first modal window pops up, click the new button - & gt; Popup modal form, I in the view definition method of a popup modal form function, on the button to call this method through an onclick event; Give the button button binding a click on the click event,

First of all, to obtain new this button, click on the button, if the pop-up modal form, said binding success, no, said binding failure; Popup modal form, the next step is to get through the onclick on modal form; To invoke a modal, this method (called modal need to refer to a plug-in bootstrap. Min. Js); Feature: the first modal window pops up, click the new button - & gt; Popup modal form, I in the view definition method of a popup modal form function, on the button to call this method through an onclick event; Give the button button binding a click on the click event,

Modification: probably similar to the new operation, click the modify button, pop-up modal form and the data query, on the modal form, fill in the data need to be modified, the modified data are saved; (there are two kinds of data query method: according to the college id to check my database in to modify this data, query good data on the modal form inside; There is a way, to obtain the current row data),
Should pay attention to a problem, here on the modal form input data, and then close it, when you open the modal form again, the data is still there, it was not clear, and the operation of the users want is once again opened the modal form, data is empty inside, an empty modal form,
There is a way to solve this problem,

After reset the form, click on the save button, the condition judgment, the form data can not be empty, to save an operation, it defines a function, this method is mainly a save operation, and we will go to the modal form inside our on the save button to add an onclick, onclick invoking this method, need to add data access, access to the data to the controller; Controller through a method to carry on add to the database, I obtain the data transmitted to the controller via post, in the post, the first argument, URL, the specific position,
The second argument: do you want to pass parameters, with key/value pair;
The third argument: the callback function; After passing data, and transfer data to determine whether complete, give users to set some hints,

In the controller defines a method to receive and view the data, in method to instantiate the data, in the assignment of it after assignment, it is new, finished, save the data to determine whether the data, new data for null/data are the same,


In the controller defines a method to receive and view the data, in method to instantiate the data, in the assignment of it after the assignment is to modify, modify the data is completed, to judge whether the data is changed, the data for null/data is modified,
4 remove
Delete a its modal form, in removing modal dialog form is when you delete the style of the modal dialog, in the view page write delete code to write delete button click event? A new url (path) custom columns to delete template open load layer? Close the load layer? Close the modal dialog
First of all we write in the HTML code of a modal dialog form code, a delete, it is needed when an operation popups modal form

Query need to delete the data, access to the data to the controller; Controller through a method again to the database to delete, I through the method sends the data to the controller, the first argument, Url, the specific position, the second parameter: do you want to pass parameters, with key/value pair, the third argument: the callback function; After passing data, and transfer data to determine whether to delete, give users to set some hints,


In the controller defines a method to receive and view the data, in method to instantiate the data, in the assignment of it after the assignment is to delete, delete the data is completed, to judge whether the data deleted successfully, whether there is any data/cannot delete/remove abnormal data,




  • Related