ASP. NET Mvc+ef Framework +easyui Implementation Rights Management Series (1)-Frame construction

Source: Internet
Author: User
Tags visual studio 2010

Original: ASP. NET MVC+EF Framework +easyui Implementation Rights Management Series (1)-Frame construction

ASP. NET Mvc+ef Framework +easyui implement permission tube series (opening)

  Preface: This blog beginning we will step to achieve this permission system preliminary design-framework construction, first of all I want to say is that we need to develop tools Visual Studio 2012 or 10 also line, followed by we want to have SQL Server database, if it is Visual Studio 2010, you also want to install the MVC4 development files, this is it? I do not remember, who can answer me a bit, I have been using 2012, are integrated well, so not very clear. Because this blog is relatively simple, just to build a simple architecture, so I would like to take a look at the MVC knowledge Supplement, I will be interspersed with the introduction of the project encountered in the technology, the following to start today's tour.

Before learning MVC, it is necessary to know these points of knowledge (automatic attributes, implicit type Var, object initializers and set initializers, anonymous classes, extension methods, lambda expressions), if you do not already know, please see my simple introduction below, if you have known, you can skim this blog , look at the preliminary image of the project I built below, and then we'll start with a brief introduction to the next article.

1. Automatic properties

(1) Automatic attributes (auto-implemented properties), C # Automatic properties can avoid the original we manually declare a private member variable and the writing of the property get,set.

public class Kencery//Declare a Kencery class

{

public int id{get;set;} Primary Key ID

public string name{get;private set;} Read-only property name

public int age{get;set;} Age

}

2. implicitly-typed Var

(1) Now more and more projects you can see VAR, what does this mean? Actually, that's the c#3.0 new feature. The Var,var keyword instructs the compiler to infer the type of a variable based on the expression on the right side of the initialization statement.

var kencery= "Good evening for everyone"; Defining variables

var list=new list<int> (); Define a list collection

var kencery=new{id=1,name= "HYL", age=24}//object initialization defined type

var geners = from N in storecontract.productcatalogs

where N.issystem = = False

Select N;

Return View (geners);

The use of LINQ, this in the back we will be a lot of use, we have not learned can self-study.

(2) var has such a large function, then he has what shortcomings, and we are listed here roughly

1) You can use VAR only if you declare and initialize a local variable in the same statement, and you cannot initialize the variable to null, a method group, or an anonymous method.

2) var cannot be used for class-scoped domains.

3) variables declared by Var cannot be used in an initialization expression, in other words, this expression is valid: int i= (I=20), but the following expression generates a compilation error: Var i= (i=20).

4) You cannot initialize multiple implicitly-typed variables in the same statement.

5) If there is a type named var in the scope, the var keyword resolves to the type name instead of being processed as part of the implicit type local variable declaration.

3. Anonymous class

(1) Encapsulates a set of read-only properties into a single object without first displaying the definition of a type, the type name is generated by the compiler, and cannot be used at the source level, and the type of each property is inferred by the compiler. [Var]

(2) An expression used to initialize a property cannot be null, an anonymous function, or a pointer type.

var kencery=new{id=1,name= "HYL", age=24}

4. Object initializers and collection initializers

(1) The object initializer uses the compiler to assign values to fields or properties that are visible to the object externally, or to call the constructor implicitly, or to assign a field or property to one or more.

List<kencery> kencery=new list<kencery>{//kencery class
New Kencery{id=1,name= "Hanyinglong", age=19},

New kencery{id=2,name= "HYL"},

Null

};

Person p=new person{id=1,name= "HYL", age=19};

5. Extension methods

(1) An extension method is a special static method that is defined in a static class, but can be invoked on an object of another class to invoke an instance method. Thus, by extending the method, we can extend the functionality of a type without modifying a type, and this method does not produce new types, but rather extends the functionality by adding new methods to existing classes.

(2) When extending an existing class, we need to write all the extension methods in a static class, which is equivalent to the container where the extension method is stored, and all the extension methods can be written here. The extension method differs from the normal method by declaring that the first parameter of the extension method starts with the This keyword followed by the extended type, and then the actual argument list.

public static return type extension method name (this is the type parameter name to extend [, extension method parameter list])

{

}

public static int ToInt32 (this string s)//extension method converts a string to an orthopedic

{

Return Int32.Parse (s);

}

6. Lambda expression

(1) A "lambda expression" is an anonymous function that can contain expressions and statements that can be used to create delegates.

(2) operator =>, the operator reads: "Goes to".

(3) Format: (Input parameters) =>expression

delegate bool Deldemo (int a,int b); Defining delegates

Deldemo lambda= (int a,int b) =>a>b//using a LAMBDA expression to indicate whether a is greater than B

Console.WriteLine (Lambda (1,4));

7. Project Overall framework Flowchart

(1) above pulled so much, in fact, with our blog today is no use, just some preparation work, but also review these points of knowledge, below we will create a new MVC4 program, how to create a MVC4 program, I believe we have already will, and then build the framework, build the framework:

(2) then we LYZJ.UserLimitMVC.Model layer design database, in which an empty EDMX model is created:

(3) above we have established four class library and a MVC4.0 project, we look carefully, if everyone on the role of the four class library is not very clear, I suggest you can go to see the three-tier architecture, or the following message to me, now do not go out to write.

(4) This blog is here to end, the next blog we began to tell: using the face of interface programming into the database access layer is introduced.

  

Kencery back to the beginning of this series

  

ASP. NET Mvc+ef Framework +easyui Implementation Rights Management Series (1)-Frame construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.