Stage
|
Details
|
Receive first request for the application
|
In the Global.asax file, Route objects are added to the RouteTable object.
|
Perform routing
|
The UrlRoutingModule module uses the first matching Route object in the RouteTable collection to create the RouteData object, which it then uses to create a RequestContext object.
|
Create MVC request handler
|
The MvcRouteHandler object creates an instance of the MvcHandler class and passes the RequestContext instance to the handler.
|
Create controller
|
The MvcHandler object uses the RequestContext instance to identify the IControllerFactory object (typically an instance of the DefaultControllerFactory class) to create the controller instance with.
|
Execute controller
|
The MvcHandler instance calls the controller's Execute method.
|
Invoke action
|
For controllers that inherit from the ControllerBase class, the ControllerActionInvoker object that is associated with the controller determines which action method of the controller class to call, and then calls that method.
|
Execute result
|
The action method receives user input, prepares the appropriate response data, and then executes the result by returning a result type. The built-in result types that can be executed include the following: ViewResult (which renders a view and is the most-often used result type), RedirectToRouteResult, RedirectResult, ContentResult, JsonResult, FileResult, and EmptyResult.
|
Language Integrated Query (LINQ)
参考:http://social.msdn.microsoft.com/search/en-us?query=LINQ&x=0&y=0
{
static void Main()
{
int[] numbers = { 5, 10, 8, 3, 6, 12};
//Query syntax:
IEnumerable< int> numQuery1 =
from num in numbers
where num % 2 == 0
orderby num
select num;
//Method syntax:
IEnumerable< int> numQuery2 = numbers.Where(num => num % 2 == 0).OrderBy(n => n);
foreach ( int i in numQuery1)
{
Console.Write(i + " ");
}
Console.WriteLine(System.Environment.NewLine);
foreach ( int i in numQuery2)
{
Console.Write(i + " ");
}
// Keep the console open in debug mode.
Console.WriteLine(System.Environment.NewLine);
Console.WriteLine( "Press any key to exit");
Console.ReadKey();
}
}
Lambda Expressions
http://msdn.microsoft.com/enus/library/bb397687.aspx
http://www.cnblogs.com/JeffreyZhao/archive/2009/08/07/from-delegate-to-others-2.html
Note in the previous example that the body of an expression lambda can consist of a method call. However, if you are creating expression trees that will be consumed in another domain, such as SQL Server, you should not use method calls in lambda expressions. The methods will have no meaning outside the context of the .NET common language runtime.
Linq to Sql http://msdn.microsoft.com/en-us/library/bb399398.aspx
- // Northwnd inherits from System.Data.Linq.DataContext.
- Northwnd nw = new Northwnd(@"northwnd.mdf");
- // or, if you are not using SQL Server Express
- // Northwnd nw = new Northwnd("Database=Northwind;Server=server_name;Integrated Security=SSPI");
- var companyNameQuery =
- from cust in nw.Customers
- where cust.City == "London"
- select cust.CompanyName;
- foreach (var customer in companyNameQuery)
- {
- Console.WriteLine(customer);
- }
Query Expression Syntax Examples: Ordering
Query Expression Syntax Examples: Aggregate Operators
Query Expression Syntax Examples: Partitioning
Query Expression Syntax Examples: Join Operators
Query Expression Syntax Examples: Element Operators
转载于:https://blog.51cto.com/maben/774306