.net 记录

Stack Overflow 2016最新架构探秘

http://www.infoq.com/cn/news/2016/03/Stack-Overflow-architecture-insi#rd

 NET Core R2安装教程及Hello示例

http://www.cnblogs.com/seayxu/p/5508148.html

Net Core的背景

http://www.rm5u.com/csharp/netcore-bg.html

OAuth认证

http://www.cnblogs.com/Irving/p/4810131.html

 

一、Linq通用方法

public class LinqHelper
    {
       /// <summary>
       /// 排序
       /// </summary>
       /// <typeparam name="T"></typeparam>
       /// <param name="source"></param>
       /// <param name="sortExpression"></param>
       /// <param name="sortDirection"></param>
       /// <returns></returns>
        public static IQueryable<T> DataSorting<T>(IQueryable<T> source, string sortExpression, string sortDirection)
        {
            //错误查询
            if(string.IsNullOrEmpty(sortExpression) || string.IsNullOrEmpty(sortDirection))
            {
                return source;
            }
            string sortingDir = string.Empty;
            if (sortDirection.ToUpper().Trim() == "ASC")
                sortingDir = "OrderBy";
            else if (sortDirection.ToUpper().Trim() == "DESC")
                sortingDir = "OrderByDescending";
            ParameterExpression param = Expression.Parameter(typeof(T), sortExpression);
            PropertyInfo pi = typeof(T).GetProperty(sortExpression);
            Type[] types = new Type[2];
            types[0] = typeof(T);
            types[1] = pi.PropertyType;
            Expression expr = Expression.Call(typeof(Queryable), sortingDir, types, source.Expression, Expression.Lambda(Expression.Property(param, sortExpression), param));
            IQueryable<T> query = source.AsQueryable().Provider.CreateQuery<T>(expr);
            return query;
        }
       /// <summary>
       /// 分页
       /// </summary>
       /// <typeparam name="T"></typeparam>
       /// <param name="source"></param>
       /// <param name="pageNumber"></param>
       /// <param name="pageSize"></param>
       /// <returns></returns>
        public static IQueryable<T> DataPaging<T>(IQueryable<T> source, int pageNumber, int pageSize)
        {
            if (pageNumber <= 1)
            {
                return source.Take(pageSize);
            }
            else
            {
                return source.Skip((pageNumber - 1) * pageSize).Take(pageSize);
            }
        }
       /// <summary>
        /// 排序并分页 
       /// </summary>
       /// <typeparam name="T"></typeparam>
       /// <param name="source"></param>
       /// <param name="sortExpression"></param>
       /// <param name="sortDirection"></param>
       /// <param name="pageNumber"></param>
       /// <param name="pageSize"></param>
       /// <returns></returns>
        public static IQueryable<T> SortingAndPaging<T>(IQueryable<T> source, string sortExpression, string sortDirection, int pageNumber, int pageSize)
        {
            IQueryable<T> query = DataSorting<T>(source, sortExpression, sortDirection);
            return DataPaging(query, pageNumber, pageSize);
        }
    }

 

二、分页

 public class GridPager
    {
      
        public int rows { get; set; }//每页行数
        public int page { get; set; }//当前页是第几页
        public string order { get; set; }//排序方式
        public string sort { get; set; }//排序列
        public int totalRows { get; set; }//总行数
        public int totalPages //总页数
        {
            get
            {
                return (int)Math.Ceiling((float)totalRows / (float)rows);
            }
        }
    }
     public class GridRows<T>
     {
         public List<T> rows { get; set; }
         public int total { get; set; }
     }

 

三、 Sqlite DateTime 类型 读取和写入格式 注意的问题

http://androidguy.blog.51cto.com/974126/214337/

 

四、Linq交集、差集,并集,去重

using System.Linq;
  
List<string> ListA = new List<string>();
List<string> ListB = new List<string>();
List<string> ListResult = new List<string>();

 
ListResult = ListA.Distinct().ToList();//去重
ListResult = ListA.Except(ListB).ToList();//差集
ListResult= ListA.Union(ListB).ToList();  //并集
ListResult = ListA.Intersect(ListB).ToList();//交集

 

五、MVC视频教程

MVC视频教程:链接: http://pan.baidu.com/s/1qY4DpPq 密码: wyut

 

六、RazorPad

https://github.com/RazorPad/RazorPad

 

七、Linq表达式、Lambda表达式你更喜欢哪个?

http://www.cnblogs.com/zhaopei/p/5746414.html

 

八、Firefox 自动化测试插件:selenium-ide

https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/?src=userprofile

 

九、学习一下代码片段如何使用,有助于提供开发效率。

 
十、反编译工具:JetBrains decompiler
 
十一、Dapper高级使用

 

posted @ 2016-05-20 21:22  Rain520  阅读(315)  评论(0编辑  收藏  举报