public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) { HashSet<TKey> hashSe ...
分类:
编程语言 时间:
2019-04-23 11:11:52
阅读次数:
153
1 条件判断是否要加过滤条件 public static IQueryable<T> WhereIf<T>( this IQueryable<T> source, Expression<Func<T, bool>> predicate, bool condition) { source.CheckN ...
分类:
其他好文 时间:
2019-04-11 12:04:28
阅读次数:
100
LINQ查询方法一共提供了两种扩展方法,在System.Linq命名空间下,有两个静态类:Enumerable类,它针对继承了IEnumerable<T>接口的集合进行扩展;Queryable类,针对继承了IQueryable<T>接口的集合进行扩展。我们会发现接口IQueryable<T>实际也是 ...
分类:
编程语言 时间:
2019-04-06 17:12:59
阅读次数:
184
首先给Grid添加BindingSource,类型为BindingForForm2。或者设置Grid的DataSource为IEnumerable<BindingForForm2>。 BindingForForm2类型如下。 public class BindingForForm2 { public ...
IQueryable<TPT_ECN_MSTR> q = db.TPT_ECN_MSTRS.AsNoTracking(); if (_OrdDateFr == DateTime.MinValue && _OrdDateTo == DateTime.MaxValue) return q.Where(p ...
分类:
其他好文 时间:
2019-02-12 12:54:04
阅读次数:
318
public ActionResult Index(IEnumerable<HttpPostedFileBase> files) { foreach (var file in files) { if (file.ContentLength > 0) { var fileName = Path.Get ...
分类:
Web程序 时间:
2019-01-20 11:49:28
阅读次数:
185
Zip 方法允许把序列中的元素通过交织将 IEnumerable 序列连接在一起。Zip 是一种基于 IEnumerable 的扩展方法。例如,将具有年龄的名称集合压缩在一起: 将会生成包含三个元素的 IEnumerable <string>: image.png image.png 如果一个序列比 ...
分类:
编程语言 时间:
2019-01-13 02:01:25
阅读次数:
189
数据加载 如下这样的一个lamda查询语句,不会立马去查询数据库,只有当需要用时去调用(如取某行,取某个字段、聚合),才会去操作数据库,EF中本身的查询方法返回的都是IQueryable接口。 链接:IEnumerable和IQueryable接口说明 其中聚合函数会影响数据加载,诸如:toList ...
分类:
其他好文 时间:
2019-01-13 00:13:11
阅读次数:
157
【译】《C# 小技巧 -- 编写更优雅的 C#》原书名《C# Tips -- Write Better C#》 目录 介绍(Introduction) 第一部分:各种小技巧(Part 1: Assorted Tips) 使用 LINQ 合并 IEnumerable 序列(Merging IEnume ...
Json.net 序列化程序会将.Net 值转换为json值,表格中是支持转换的对象类型; .net 对象类型 转换后的Json 类型 IList, IEnumerable, IList<T>, Array,datatable json数组 IDictionary, IDictionary<TKey ...
分类:
Web程序 时间:
2019-01-13 00:08:49
阅读次数:
253