Among the new C # how Linq

Among the new C # how Linq

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

In C # should need to add what conditions?
We know that in the first C # query need to add the appropriate data to perform the corresponding operation according to the new conditions as the corresponding fields, the receiving controller (Controller) and page two portions which C #, a first controller wherein the transfer functions according to user needs to perform the role of the corresponding behavior (operation method), while calls to business logic behavior model, the result returned to the user (view) a second intermediary: separating view and model, so the model view and their duties The controller assigned them to interact. Responsible only for data transfer, is not responsible. Two roles of the controller can be represented this way:
Here Insert Picture Description
while the page is among major beautification view gives users visual beauty;

  1. How do you add? The first step: the need for modal pop-up box on the page, let it have new options and conditions, a further saving method to add function function name according to the conditions, click the Add button to open the modal box
    function saveYuanGongInsert () {
    $ ( "#formInsetYuanGong") [0] .reset ()
    // form name form ID; [0] .reset () resets the form clear the form
    $ ( "# modalInsetEmployee") Modal ( "Show");.
    // entire mold state box ID "show" is the English meaning of the show is the show, the presentation of
    the second step: page data is acquired, then eleven acquired by name or ID required conditions pages according
    var EmployeeNumber = $ ( "# formInsetYuanGong [name = 'EmployeeNumber'] ") val ( );. // number
    var EmployeeName = $ (" # formInsetYuanGong [name = 'EmployeeName'] ".) val (); // name
    var Phone = $ (" # formInsetYuanGong [name = 'phone'] ") val ( );. // telephone
    var Cellphone = $ (" # formInsetYuanGong [name = 'Cellphone'] ") val ();. // phone
    var DepartmentName = $ (" # formInsetYuanGong [name = 'DepartmentID'] ") val ( );. // sector
    var PositionName = $("#formInsetYuanGong [name=‘PositionID’]").val();//职位
    var Address = $("#formInsetYuanGong [name=‘Address’]").val();//地址
    var Remark = $("#formInsetYuanGong [name=‘Remark’]").val();//备注
    Note: var is declared var name behind the name can be named, but must be consistent when judging the integrity of data, and the same after the equal sign is a form of ID with their name form of the name on the back of the form and must form database pass over the naming consistent, otherwise in view (page) data transfer, but the data is empty or data anomalies;
    The third step: determining the integrity of the data when determining where data integrity should be noted that the difference between data and drop-down box field
    IF (the DepartmentName> 0
    ! && PositionName> = 0 && EmployeeNumber ""! && EmployeeName = "" && Phone! = "" && Cellphone! = "" && Address! = "" && Remark! = "")
    we can see the data drop-down box his criteria and fields are not the same, the drop-down box data is determined to be greater than zero , compared data is greater than zero, the criteria field is not equal to empty
    step 4: select form submission form submission then comes also submit several different ways;
    Eg of: Ajax (form sheet) get.json submission and asynchronous post submission, get submitted; presented in a way also means that the scope and methods, so be selected according to the desired; and ajaxSubmit form submission was filed form () submit the form used here: we submitted directly through the form of words after submitting the current page jumps to the form of action points to the page. ajaxSubmit (obj) method is a plug-in inside jquery.form.js jQuery method, so you need to use this method to introduce this plug-in
    so that part of the code page was written so that the remaining portion of the controller
    first public ActionResultInsertEmployee (PW_Employee pwEmployee, PW_User pwUser) MVC in public means public, ActionResult Action is the result of return. ActionResult have multiple derived classes, each subclass functions are different, not all subclasses need to return to view View, some direct return flow, return some string and so on. ActionResult is an abstract class that defines a unique ExecuteResult method, as a parameter, the result is returned ActionResult method performed when the controller of the type of controller type method may return a directly or indirectly inherit from the abstract class ActionResult, if the return non ActionResult type, the controller converts the result to be a ContentResult type. The default ControllerActionInvoker call ActionResult.ExecuteResult method generates a response results.
    Here Insert Picture Description
    Among the database determines whether the same information exists,
    the FROM clause can be obtained from the database tables to one or more sources. Source database table is usually named table, but it may be a view or sub-query. For more detailed information related to the sub-queries, we will introduce later. Upon acquiring the plurality of source tables, JOIN operators have a plurality of source tables are combined and generate a large table. Note: JOIN operator is determined from left to right, each of the two tables JOIN operator will be combined into one large table, using this principle can be strung together a series of JOIN operator, in order to achieve three or a combination of more tables.
    WhereDepending on what is where, as shown in the judgment employee number and name were screened to determine whether the same employee information
    SELECTStatement is used to select data from the database. The results are stored in a result table, called a result set. Among the new process in a new one table at the same time need to consider whether other association table to judge according to the required additional employee information table among the field, then the employee number and other information specific to relate to user roles and user details so this time the user tables and user roles schedules also need to type the user ID and user ID in order to determine the relationship between the tables, forms new order: the user table -> employee table -> user roles list (which employees table and user roles schedule new order may be interchanged)
    int = countUser (from tbUser in myModels.PW_User
    WHERE == pwUser.UserID tbUser.UserID
    SELECT tbUser) .Count ();
    user based on the user ID table determination myModels. PW_User.Add (pwUser);. MyModels is an example of a user table out .Add is added (to pass over the new user data table)

Add the difference and AddRange?

Add:将指定的1对象添加到....当中(添加一条)  AddRange:向....末尾添加数据(添加多条)

When groups operate, AddRange Add replaced with AddRange allows us to join a one-time thing to join, rather than each time plus one, so obviously you can speed up. Almost all of the windows control and support Add AddRange two ways. According to the need to use
Here Insert Picture Description
the next step is to add the user role list, first of all get to the same table and then have the new user according to the new user ID as a condition, new employees table, the schedule determines when the user types in a new role to add users a new type of user and user ID as the database according to a condition which is equal to the last value of the type of user is the new general staff 5;
Here Insert Picture Description
after completion determining users and user roles last successful new employee table schedule!

Guess you like

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