linq增删改查的语法介绍_第1页
linq增删改查的语法介绍_第2页
linq增删改查的语法介绍_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、linq语法应用的很多。下面我将linq增删改查的语法介绍给大家,供大家学习和参考。1.查询语法(分为查询列表和条件查询)A. 查询列表public IQueryable getListl nfo() HotelDataClasses hoteldata=new HotelDataClasses ();IQueryable fianinfo = from h inhoteldata.Htel_ Finan cialPayeeselect new Htel_ Fin acialPayeeModelFp_ID = h.Fp_ID,Fp_PayeeBa nk = h.Fp_PayeeBa nk;if

2、 (fianin fo.Cou nt() 0)retur n fianinfo;else return nu II;B. 条件查询,返回MOdel数据集/编辑信息时通过编号查询到的酒店财务收款列表信息public Htel_ Finan cialPayee GetHtel Fin acialI nfosByid(l ong id)using (HotelDataClasses hotelData = new HotelDataClasses()var info = hotelData.Htel_Fi nan cialPayee.Where(P = P.Fp_ID = id).First();r

3、eturn info;c.多表联合查询语法有2个表的:IQueryableHtel_ Fin acialPayeeModelin folist = from h in hoteldata.Htel_ Finan cialPayee join compa ny in hoteldata.BasCompa nylnfo on h.Fp_Compa nyld equals compa ny.lD into Cwhere h.Fp_Compa nyld = Con vert.To In t32(comp nanyid )select new Htel_ Fin acialPayeeModelFp_ID

4、 = h.Fp_ID,Compa nyn ame = C.First().Compa ny Name,Fp_Payee = h.Fp_Payee,Fp_PayeeCard = h.Fp_PayeeCard,Fp_PayeeBa nk = h.Fp_PayeeBa nk;return in folist;3个以上的表联合查询IQueryableP.OrderCode=OrderCode)join dic in db.Htel_Dictio nary on in f.Cha nn elID equals dic.ID into lfrom y in I.DefaultlfEmpty()from h

5、 in db.Htel_Hotelfrom cn in db.Htel_HotelENfrom en in db.Htel_HotelCNfrom ddic in db.Htel_Dictio narywhere in f.MemberlD = memberidwhere inf.H otelID = h.IDwhere inf.H otelID = cn .HotelIDwhere in f.HotelID = en .HotelIDwhere in f.Payme ntID = ddicDselect new Reservati on DetailsArrivalTime = in f.A

6、rrivalTime,Cha nn elID = in f.Cha nn elID,Cha nn elName = y.NameCN,Check In = in f.Check in.Checkout = in f.Checkout,Compa nylD = in f.Compa ny ID,2. 修改语法public bool Update in fo(Htel_ Finan cialPayee model)HotelDataClasses hoteldata = new HotelDataClasses();var info = hoteldata.Htel_Fi nan cialPaye

7、e.Where(p = p.Fp_ID = model.Fp_ID); if (in fo.Cou nt() 0)Htel_Fi nan cialPayee inf = in fo.First();in f.Fp_ID = model.Fp_ID;in f.Fp_Payee = model.Fp_Payee;in f.Fp_PayeeCard = model.Fp_PayeeCard;hoteldata.SubmitCha nges();return true;elsereturn false;3. 删除语法public bool delI nfo(stri ng id) HotelDataC

8、lasses hoteldata = new HotelDataClasses();var info = hoteldata.Htel_Fi nan cialPayee.Where(p = p.Fp_ID = Convert.ToInt32(id ).First ();hoteldata.Htel_Fi nan cialPayee.Delete On Submit(i nfo);hoteldata.SubmitCha nges();return true;4.增加语法public bool Add in fo(Htel_ Finan cialPayee model) HotelDataClasses hoteldata = new HotelDataClasses();Htel_ Finan cialPayee fin amodel = new Htel_ Finan cialPayee();fin amodel.Fp_Payee = model.Fp_Payee;fin amodel.Fp_P

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论