linq增删改查的语法介绍.doc_第1页
linq增删改查的语法介绍.doc_第2页
linq增删改查的语法介绍.doc_第3页
linq增删改查的语法介绍.doc_第4页
免费预览已结束,剩余1页可下载查看

下载本文档

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

文档简介

一课资料网/linq语法应用的很多。下面我将linq增删改查的语法介绍给大家,供大家学习和参考。1.查询语法(分为查询列表和条件查询)A.查询列表public IQueryable getListInfo( HotelDataClasses hoteldata=new HotelDataClasses (;IQueryable fianinfo = from h in hoteldata.Htel_FinancialPayee select new Htel_FinacialPayeeModelFp_ID = h.Fp_ID,Fp_PayeeBank = h.Fp_PayeeBank;if (fianinfo.Count( 0return fianinfo;else return null;B.条件查询,返回MOdel数据集/编辑信息时通过编号查询到的酒店财务收款列表信息public Htel_FinancialPayee GetHtelFinacialInfosByid(long idusing (HotelDataClasses hotelData = new HotelDataClasses(var info = hotelData.Htel_FinancialPayee.Where(P = P.Fp_ID = id.First(;return info;c.多表联合查询语法有2个表的:IQueryable infolist = from h in hoteldata.Htel_FinancialPayee join company in hoteldata.BasCompanyInfo on h.Fp_CompanyId equals company.ID into Cwhere h.Fp_CompanyId = Convert.ToInt32(compnanyid select new Htel_FinacialPayeeModelFp_ID = h.Fp_ID,Companyname = C.First(.CompanyName,Fp_Payee = h.Fp_Payee,Fp_PayeeCard = h.Fp_PayeeCard,Fp_PayeeBank = h.Fp_PayeeBank;return infolist;3个以上的表联合查询IQueryable info = from inf in db.Htel_OrderInfo.Where(P=P.OrderCode=OrderCode join dic in db.Htel_Dictionary on inf.ChannelID equals dic.ID into lfrom y in l.DefaultIfEmpty(from h in db.Htel_Hotelfrom cn in db.Htel_HotelENfrom en in db.Htel_HotelCNfrom ddic in db.Htel_Dictionarywhere inf.MemberID = memberidwhere inf.HotelID = h.IDwhere inf.HotelID = cn.HotelIDwhere inf.HotelID = en.HotelIDwhere inf.PaymentID = ddic.IDselect new ReservationDetailsArrivalTime = inf.ArrivalTime,ChannelID = inf.ChannelID,ChannelName = y.NameCN,CheckIn = inf.Checkin,CheckOut = inf.Checkout,CompanyID = inf.CompanyID,2.修改语法public bool Updateinfo(Htel_FinancialPayee modelHotelDataClasses hoteldata = new HotelDataClasses(;var info = hoteldata.Htel_FinancialPayee.Where(p = p.Fp_ID = model.Fp_ID;if (info.Count( 0Htel_FinancialPayee inf = info.First(;inf.Fp_ID = model.Fp_ID;inf.Fp_Payee = model.Fp_Payee;inf.Fp_PayeeCard = model.Fp_PayeeCard;hoteldata.SubmitChanges(;return true;elsereturn false;3.删除语法public bool delInfo(string id HotelDataClasses hoteldata = new HotelDataClasses(;var info = hoteldata.Htel_FinancialPayee.Where(p = p.Fp_ID = Convert.ToInt32(id .First (;hoteldata.Htel_FinancialPayee.DeleteOnSubmit(info;hoteldata.SubmitChanges(;return true;4.增加语法public bool Addinfo(Htel_FinancialPayee model HotelDataClasses hoteldata = new HotelDataClasses(;Htel_FinancialPayee finamodel = new Htel_FinancialPayee(;finamodel.Fp_Payee = model.Fp_Payee;finamodel.Fp_P

温馨提示

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

评论

0/150

提交评论