Linq
KingCruel
这个作者很懒,什么都没留下…
展开
-
LINQ常用语句
1、数组排序void ArrLinq() { string temp = null; int[] arr = new int[] { 8, 5, 89, 3, 56, 4, 1, 58 }; var m = from n in arr where n < 58 orderby n select n;原创 2013-03-21 09:44:19 · 890 阅读 · 0 评论 -
Linq to SQL: 自定义排序
某些时候我们需要按照某个特定的序列来完成结果排序,比如说按in条件中的Id顺序返回文章。比如按此顺序排序:1,5,2,6,3,7,4,9SQL语句如下:select * from pdt_Music where MusicID in(1,2,3,4,5,6,7,8,9)order by CHARINDEX(RTRIM(CAST(MusicID as NCHAR)),'5,2,8,原创 2014-01-13 11:18:13 · 3828 阅读 · 0 评论 -
LINQ,EF联合查询join GroupBy分组
public object GetListAdmin() { //return db_C56.Admins // .Where(a => a.Status != "D").ToList(); var query1 = db_C56.Admins.Join(db_C56.Area, a => a.AreaI原创 2013-11-11 18:01:20 · 38161 阅读 · 1 评论 -
Linq not in 查询 时间字符串string转datetime类型查询
1、SQL查询原型:select * from SymptomPic where PicPath not in ('图片路径1','ssssss','sdsd','sdsd') and SymptomID = 12Linq语句:from t in db.SymptomPic where t.PicPath != "图片路径1','ssssss','sdsd','sdsd" &&原创 2016-03-31 16:35:04 · 2196 阅读 · 0 评论 -
Linq基本查询 StartsWith、EndWith、Contains
1、基本查询 from g in TblGroups select g2、带条件查询 from g in TblGroups where g.Name.Contains("组") select g3、查询显示不同的列 from g in TblGroups select new { g.Name,原创 2013-08-17 13:10:02 · 2832 阅读 · 0 评论