Linq增刪改查語法大全

2021-06-16 07:18:43 字數 1357 閱讀 9487

1.查詢語法(分為查詢列表和條件查詢)

a.查詢列表

public iqueryablegetlistinfo() ;

if (fianinfo.count() > 0)

else

}b.條件查詢,返回model資料集

//編輯資訊時通過編號查詢到的酒店財務收款列表資訊

public htel_financialpayee gethtelfinacialinfosbyid(long id)

}c.多表聯合查詢語法

有2個表的:

iqueryableinfolist = from h in hoteldata.htel_financialpayee

join company in hoteldata.bascompanyinfo on h.fp_companyid equals company.id into c

where h.fp_companyid == convert.toint32(compnanyid )

select new htel_finacialpayeemodel

;return infolist;

3個以上的表聯合查詢

iqueryableinfo = from inf in db.htel_orderinfo.where(p=>p.ordercode==ordercode)

join dic in db.htel_dictionary on inf.channelid equals dic.id into l

from y in l.defaultifempty()

from h in db.htel_hotel

from cn in db.htel_hotelen

from en in db.htel_hotelcn

from ddic in db.htel_dictionary

where inf.memberid == memberid

where inf.hotelid == h.id

where inf.hotelid == cn.hotelid

where inf.hotelid == en.hotelid

where inf.paymentid == ddic.id

select new reservationdetails

2.修改語法

public bool updateinfo(htel_financialpayee model)

else

}3.刪除語法

public bool delinfo(string id)

4.增加語法

public bool addinfo(htel_financialpayee model)

LINQ增刪改查

linq language integrated query 語言整合查詢是一組用於c 和 visual basic 從技術角度而言,linq定義了大約40個查詢操作符,如select from in where以及order by c 中 使用這些操作符可以編寫查詢語句。不過,這些查詢還可以基於很...

sql增刪改查語法

1.使用insert插入單行資料 語法 insert into 表名 列名 values 列值 例 insert into strdents 姓名,性別,出生日期 values 斌 男 1993 6 15 注意 into可以省略 列名列值用逗號分開 列值用單引號因上 如果省略表名,將依次插入所有列 ...

SQL Server基礎語法 增刪改查

1.插入單行資料insert into 表名 列名 values 值列表 當列名列有預設值時,輸入 default 2.插入多行資料 將現有資料庫值插入到新資料庫中 方法1 insert into 表名 列名 必須預先建立新的資料庫 select 列名 from 源表名 方法2 select 列名 ...