잊지 않겠습니다.

  • 신속한 데이터의 개발
  • Database, XML, Data Array에서 같은 Query를 사용해서 사용 가능

1. metadata의 생성

 [Table(Name = "Customers")] : Table에 Mapping이 되는 것을 나타내는 Attribute
 [Column(IsPrimayKey = true)]
 [Column(Storage=_City)] : Column Mapping을 나타내는 Attribute

[Table(Name = "Customers")]
 public class Customer
 {
     [Column(IsPrimaryKey = true)]
     public string CustomerID;    
     private string _City;

     [Column(Storage = "_City")]
     public string City
     {
         get { return this._City; } 
         set { this._City = value;}
     }
 }

2. DataContext 선언

    : MetaData가 정해져 있는 데이터와의 연결을 선언 (DB Connection과 동일) 

    DataContext db = new DataContext(@"Data Source =(local, Inital Catalog= Northwind... ")
    db.Log = Console.Out;
    Table<Customer> customers = db.GetTable<Customer>();
    var cust = from c in customers 
                    where c.City = "Seoul" SELECT C;

3. Programming...

  

IDE의 이용

  1. LINQ Class 의 추가
  2. DB를 선택, DB Table의 추가
  3. Namespace에 Database에 관한 LINQ Class의 자동 생성
  4. Hall, Dall과 비슷한 소스가 모두 자동으로 생성된다.
    Northwind db = new Northwind();
    var cust = from c in db.Customer 
                    where c.City = "Seoul" SELECT C;
Posted by Y2K
,