https://www.cnblogs.com/May-day/p/7490334.html 一,OrderBy排序在MDSN中有两种使用方法,如下 1>第一种方法的使用,就是根据某个字段排序,使用默认的比较器(Comparer<T>.default),如下,由于Dictionary是继承IEnumerable的,所以这里可以使用Dictionary作为排序集合, using System; using System.Collections.Generic; using System.L
之前网上搜索的相关方法都是使用了反射的方法来动态获取字段,以实现动态linq排序,但是因为项目组觉得此方法效率低下,所以不予采纳. 所以有了以下代码 public interface IBase{ dynamic GetField(string field); } public class Employee : IBase { public int ID { get; set; } public string FName { get; set; } public int Age { get; s
1.通用方法 2.调用 -----------------------------1.------------------------------------------- public class CommonRepository<T> where T : class,new() { /// <summary> /// LinQ分页查询 /// </summary> /// <param name="source">条件查询之后的Lis
项目查询数据库使用的是linq 语法,可是后期需要用到不同字段的排序.各种纠结! 在网上找了各种资料 后面才找到两种方法 using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Text; namespace Rose.Repository.Repositories { public