随笔分类 -  Linq

主要是关于Linq的收集
摘要:最近项目中用到了Linq中Except,Distinct,Left Join这几个运算,这篇简单的记录一下这几种情形。Except 基础类型使用Linq的运算很简单,下面用来计算两个集合的差 int[] a = {1, 2, 3, 4}; int[] b = {2, 3, 4, 5}; var reslut = a.Except(b); result 用来返回a有,b没有的值,计算结果是1。 自定义类型实现Except class Employee { public int ID... 阅读全文
posted @ 2013-02-21 16:32 南潇湘 阅读(480) 评论(0) 推荐(0)
摘要:public IQueryable<BBS_Theme> GetListPage(int PageSize, int PageIndex, NameValueCollection nvcParamWhere, NameValueCollection nvcorderby, ref int AllCount) { #region where var searchPredicate = PredicateExtensions.True<BBS_Theme>(); if (nvcParamWhere != null) { ... 阅读全文
posted @ 2013-01-07 18:00 南潇湘 阅读(2615) 评论(0) 推荐(0)
摘要:当要输出 类别 ----类别下的小分类 类别-----类别下的小分类Model /// <summary> /// 词条的列表 有百科类型 /// </summary> public class WordList { public string BaikeType { get; set; } public Guid BaikeTypeID { get; set; } public List<Word> List { get; set; } }Linq查询语句:var list = from t in _db.BaiKeType select new Word 阅读全文
posted @ 2012-09-26 17:39 南潇湘 阅读(169) 评论(0) 推荐(0)
摘要:1.public IEnumerable<M_Student> ReadCollegeAndName(String collnum, String name) { return from s in dc.M_Student where(!String.IsNullOrEmpty(collnum) ? s.CollegeNum.Equals(collnum) : true) &&(!string.IsNullOrEmpty(name) ? s.Name.Contains(name) : true) select s; }2.利用Linq执行SQL,运用SQL强大的拼接 阅读全文
posted @ 2012-08-06 17:23 南潇湘 阅读(365) 评论(0) 推荐(0)