Linq 中查詢乙個表中指定的字段

2021-06-22 06:53:18 字數 442 閱讀 1098

linq中查詢乙個表中指定的幾個字段:

var ts = t.findallitems().where(p => p.companyid == cursiteuser.companyid).select(s => new ).distinct().tolist().orderbydescending(s => s.billperiod).take(24);

//   findallitems()為查詢對應表的所有資料的方法;

// where 裡面為查詢條件

// select 為查詢的篩選條件  new{}  裡面就是要查詢的字段

//distinct() 為去除重複的查詢

//tolist() 為將查詢轉換為list<>

//orderbydescending()  表示排序欄位及排序方法(倒序排列)

//take(n)  表示查詢前n條資料;

Linq中查詢乙個表中指定的幾個字段

var ts t.findallitems where p p.companyid cursiteuser.companyid select s new distinct tolist orderbydescending s s.billperiod take 24 findallitems 為查詢...

乙個關於HINT中指定索引查詢的問題

insert into tmp usr card qty user id,qty select index mt cards idx mt card crtdt user id,count 0 qty from mcard.mt cards c where c.card createtime bet...

逆序乙個鍊錶中指定的區間段

1 定義乙個鍊錶,並插入資料,然後遍歷此鍊錶,當遍歷第begin次的時候,記錄下此時的迭代器beginiter,遍歷到第end次的時候記錄此時迭代器enditer 2 將beginiter到enditer區間內的內容交換 define crt secure no warnings include i...