Linq to SQL 學習路線圖

來源:互聯網
上載者:User

LINQ to SQL

1 Linq基礎

1.1 Lamada Expession

Allow the definition of anonymous methods using more concise syntax.

delegate int del(int i);

del myDelegate = x => x * x;

int j = myDelegate(5); //j = 25

public int myDelegateMethod(int i)

{

   return i*i;

}

del myDelegateUsing = new del(myDelegateMethod);

int j = myDelegateUsing (5) //j=25 

Func<Northwinds, IQueryable<Orders>, int> q =

CompiledQuery.Compile<Northwinds, int,IQueryable<Orders>>((Northwinds nw, int orderid) =>

from o in nw.Orders

where o.OrderId == orderid

select o );

Northwinds nw = new Northwinds(conn);

foreach (Orders o in q(nw, orderid))

 { ...}

1.2 Anonymous Types

An object initializer can also be used without specifying the class that will be created with the new operator. Doing that, a new class-an anonymous type- is created.  

Customer c1 = new Customer { Name = "Marco" };

var c2 = new Customer { Name = "Paolo" };

var c3 = new { Name = "Tom", Age = 31 };

var c4 = new { c2.Name, c2.Age };

var c5 = new { c1.Name, c1.Country };

var c6 = new { c1.Country, c1.Name };

1.3 Object and Collection Initializers

//使用Object Initialization Expressions

Customer customer = new Customer { Name = "Marco", Country = "Italy" };

 

var customers = new []{

    new { Name = "Marco", Discount = 4.5 },

    new { Name = "Paolo", Discount = 3.0 },

    new { Name = "Tom", Discount = 3.5 }

};

1.4 implicative Local Variable Type

var x = 2.3;             // double

var s = "sample";        // string

1.5 Extend Method

1.6 Auto property

1.7 Query syntax

2 Linq 進階

2.1 IEnumerable

2.2 IEnumerator

2.3 IQueryable

2.4 IQueryProvider

2.5 Expression Tree

3 Linq To Sql

3.1 What is Linq to Sql

LINQ to SQL is an O/RM (object relational mapping) implementationand which allows you to model a relational database using .NET classes. You can then query the database using LINQ, as well as update/insert/delete data from it.

3.2 Modeling Databases

Use a LINQ to SQL designer that provides an easy way to model and visualize a database as a LINQ to SQL object model.

3.3 Extensibility Partial Class and Method

3.4 Query Update Delete Insert Paging 

Paging with Skip()& Take() Operators

varq=query.skip(pagesize*pagenum).take(pagesize)

3.4.1 Query

3.4.2 Upate Delete Insert

3.4.3 Paging

3.5 Use StoreProcedure & User Defined Function

3.6 aspLinqDatasource others UI Controls

3.7 Executing Custom SQL Expressions & DynamicQuery

Custom SQL Expression 

DynamicQuery

3.8 Concurrent Conflict

3.9 Using DBContext

3.10 Inheritance & Relationship

3.11 Some Feature:DataLoadOptions & Caching & Lazy Loading &DataContext隔離

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.