排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术

表达式树(关键字Expression<Func<对象, 数据类型>>)可以动态的拼接lamdba表达式
//对象部分 public class TableInfo { public int Sid { get; set; } public string UserName { get; set; } public int? Sum { get; set; } public int? Max { get; set; } public int? Min { get; set; } public double Avg { get; set; } public string Father { get; set; } public string Mather { get; set; } }
构建 lamdba
var left = Expression.Parameter(typeof(TableInfo), "a"); var body = Expression.Property(left, "Max"); //Func<类名, 参数类型> Expression<Func<TableInfo, int?>> lamdba = Expression.Lambda<Func<TableInfo, int?>>(body, left); //生成的lamdba 表达式{ a => a.Max }
评价