2019年5月2日
摘要: 数据源 var list = new List<TestClass> { new TestClass{Id=1,Name="1"}, new TestClass{Id=2,Name="2"}, new TestClass{Id=3,Name="3"}, new TestClass{Id=4,Name 阅读全文
posted @ 2019-05-02 23:29 cigarlau 阅读(354) 评论(0) 推荐(0) 编辑
  2019年3月26日
摘要: .net Core中自带DI是非常简单轻量化的,但是如果批量注册就得扩展,下面使用反射进行批量注册的 1 public void AddAssembly(IServiceCollection services,string assemblyName) 2 { 3 if (!string.IsNull 阅读全文
posted @ 2019-03-26 22:50 cigarlau 阅读(250) 评论(0) 推荐(1) 编辑
  2019年3月22日
摘要: 背景:项目前端ajax请求很多都没有写error方法,所以用户体验很不好 新来的前端负责人发现这个问题,写了一个错误处理方法,如下 1 //统一处理Ajax错误方法 2 function onAjaxError(xhr, textStatus, error) { 3 if (xhr.status = 阅读全文
posted @ 2019-03-22 22:46 cigarlau 阅读(747) 评论(0) 推荐(1) 编辑
  2019年3月20日
摘要: 背景:MySQL分页查询语句为 一般页面还会获取总条数,这时候还需要一条查询总条数语句 这样数据库需要执行两次查询操作。MySQL提供了SQL_CALC_FOUND_ROWS追踪总条数的函数,FOUND_ROWS取得总条数。 上面SQL语句虽然有两个结果集,但只查询一次数据库,可以提升效率。 在as 阅读全文
posted @ 2019-03-20 15:04 cigarlau 阅读(702) 评论(0) 推荐(0) 编辑
摘要: 背景:一般使用a标签,但浏览器有时候不会下载,会打开新的标签页,很不友好 下面这段代码可以实现浏览器下载图片 1 function downPic(src,imgName) { 2 var canvas = document.createElement('canvas'); 3 var img = 阅读全文
posted @ 2019-03-20 09:50 cigarlau 阅读(621) 评论(0) 推荐(0) 编辑
  2019年3月19日
摘要: 使用反射和动态生成代码两种方式(Reflect和Emit) 反射将DataTable转为List方法 1 public static List<T> ToListByReflect<T>(this DataTable dt) where T : new() 2 { 3 List<T> ts = ne 阅读全文
posted @ 2019-03-19 22:44 cigarlau 阅读(1210) 评论(1) 推荐(1) 编辑