Linq vnese

  • View
    1.482

  • Download
    6

Embed Size (px)

DESCRIPTION

Linq tieng viet

Text of Linq vnese

  • 1. n k s IITm hiu cng ngh LINQ v ng dngMc lcI. Gii thiu v LINQ. ..................................................................................................... 6II.Gii thiu v cc truy vn LINQ. ................................................................................ 7II.1 Ba phn ca mt biu thc LINQ. ............................................................................ 7II.2 Cc d liu ngun. .................................................................................................... 9II.3 Truy vn. ................................................................................................................. 10II.3 Thc thi truy vn. .................................................................................................... 10II.4 Thc thi bt buc tc thi. ...................................................................................... 11III. Tng quan v thit k O / R......................................................................................... 11III.1 M cc O / R Designer. ......................................................................................... 12III.2 Cu hnh v to ra DataContext............................................................................. 12III.3 To t chc cc lp m c s d liu bn bn v xem. ............................... 13III.4 DataContext to ra phng php gi th tc lu tr v cc hm. ......................... 13III.5 Cu hnh mt DataContext s dng cc th tc lu tr d liu lu d liu giacc lp thc th v c s d liu. .................................................................................. 13III.6 Tha k v cc O / R Designer .............................................................................. 13IV.Cc truy vn LINQ to SQL. .................................................................................... 13IV.1 Tch ri DataContext to ra v cc lp thc th vo cc namespaces khcnhau ............................................................................................................................... 14IV.2 Lm th no : Ch nh lu tr Thc hin th tc Update, Insert, v delete ..... 14V. LINQ v cc kiu c chung c im ....................................................................... 14V.1 IEnumerable cc bin trong cc cu truy vn LINQ .............................................. 15V.2 Cho php chng trnh bin dch x l cc loi khai bo chung ........................... 15V.3 Hot ng truy vn c bn...................................................................................... 16 V.3.1 Obtaining a Data Source .................................................................................. 16 V.3.2 Filtering( Lc).................................................................................................. 17 V.3.3 Ordering (Th t) ............................................................................................ 17 V.3.4 Grouping .......................................................................................................... 17 V.3.5 Joining.............................................................................................................. 18 V.3.6 Selecting (Projections) ..................................................................................... 19V.4 Chuyn i d liu vi LINQ ..................................................................................... 19 Sinh vin thc hin Nguyn Vn Thy & Hong Mnh Gii Trang 1

2. n k s II Tm hiu cng ngh LINQ v ng dng V.4.1 Tham gia vo nhiu yu t u vo xut ra mt trnh t. .................................... 20 V.4.2 La chn mt tp hp con ca mi phn t ngun ............................................. 21 V.4.3 Chuyn i cc i tng trong b nh vo XML.............................................. 22 V.4.4 Thc hin cc hot ng trn cc phn t ngun. ............................................... 23 V.4.5 Loi cc quan h trong thao tc truy vn. ............................................................ 24 V.5.6 Truy vn m khng chuyn ha cc ngun d liu ............................................. 24 V.5.7 Trnh bin dch phi suy lun ra cc loi thng tin ............................................. 25V.6 C php truy vn vs c php phng thc. ................................................................ 26 V.6.1 Ton t truy vn chun m rng cc phng thc.............................................. 26 V.6.2 Biu thc Lambda................................................................................................ 28V.7 Cc c trng c LINQ h tr trong C#3.0 ........................................................... 29 V.7.1 Biu thc truy vn. .............................................................................................. 29 V.7.2 Implicitly Typed Variables (var) ......................................................................... 30 V.7.3 i tng, v tp hp cc gi tr u vo ............................................................ 30 V.7.4 Cc loi cha xc nh ......................................................................................... 30 V.7.5 Cc phng thc m rng ................................................................................... 31 V.7.6 Cc thuc tnh t ng thi hnh........................................................................... 31V.8 Vit cu truy vn trong C# ......................................................................................... 31V.8.1 thm cc d liu ngun ...................................................................................... 31V.9 To cc truy vn.......................................................................................................... 32 V.9.1 to mt truy vn n gin .............................................................................. 32 V.9.2 thc hin cc truy vn .................................................................................... 33 V.9.3 thm mt iu kin lc ................................................................................... 33 V.9.4 Chnh sa truy vn ............................................................................................... 33 V.9.5 nhm cc kt qu ........................................................................................... 34 V.9.6 To order the groups by their key value ................................................................ 34 V.9.7 gii thiu mt nh danh bng cch s dng let ............................................ 34 V.9.8 s dng c php phng thc trong mt biu thc truy vn ......................... 35 V.9.9 chuyn i hoc d n trong mnh select ................................................. 35VI.LINQ to SQL ........................................................................................................... 36 VI.1 Kt ni ................................................................................................................... 37Sinh vin thc hin Nguyn Vn Thy & Hong Mnh GiiTrang 2 3. n k s IITm hiu cng ngh LINQ v ng dng VI.2 Giao dch ............................................................................................................... 38 VI.3 Lnh SQL trc tip ................................................................................................ 39 Cc tham s ................................................................................................................... 39 VI.4 Cch kt ni mt c s d liu (LINQ to SQL) .................................................... 39 VI.5 Cch to c s d liu (LINQ to SQL) ................................................................. 41 VI.6 Bn c th lm g vi LINQ to SQL ..................................................................... 43VI.6.1 La chn(Select) ............................................................................................ 43VI.6.2 Cch chn hng vo trong c s d liu (LINQ to SQL) .............................. 43VI.6.3 Chn mt hng vo c s d liu ................................................................... 44VI.6.4 Cch cp nht hng trong c s d (LINQ to SQL) ...................................... 45 VI.6.5 Cp nht .............................................................................................................. 46VI.7 Cch xa hng trong c s d liu (LINQ to SQL) .......................................... 47 Xa................................................................................................................................. 50 VI.8 Quy trnh lu tr (LINQ to SQL) .......................................................................... 50 VI.8.1 Chn, cp nht v xa cc hot ng ca c s d liu trong LINQ to SQL .... 51 VI.8.2 Cch gi nhng thay i n c s d liu (LINQ to SQL) .............................. 52 VI.8.3 To cc lp LINQ to SQL c nh x vo bng c s d liu or cc khung nhn. ............................................................................................................................... 54 VI.8.4 to cc lp c nh x vo d liu bng hoc cc khung nhn trong LINQ to SQL............................................................................................................................ 54VII. LINQ to XML ......................................................................................................... 55 VII.1 nh ngha. ........................................................................................................... 55 VII.2 Thm vo trong khi lp. ....................................................................................... 56 VII.3 Xa trong khi lp.................................................................................................. 57 VII.4 Ti sao khng th x l LINQ t ng? ............................................................. 58 VII.5 Lm th no : vit mt phng thc axis LINQ to XML. ............................... 59 VII.6 Cch to mt ti liu vi Namespaces (LINQ to XML) (C#) ............................. 67 VII.7 Cch Stream XML Fragments t mt XmlReader .............................................. 69 VII.8 Cch to mt s (Tree) t mt XmlReader..................................................... 71 VII.9 Thay i cy XML trn b nh trong so vi Functional Construction (LINQ to