protected override Expression VisitLambda <T>(Expression <T> node) { if (node.Body is NewExpression) { //此处一般是在Select方法中new了匿名对象,例如users.Select(x=>new {x.Id}) return(base.VisitLambda <T>(node)); } //此处一般是在Select方法中直接选择了参数,例如users.Select(x=>x),这种情况下直接把x的所有列转换出来 var properties = ExpressionReflector.GetProperties(node.Body.Type).Values; foreach (var item in properties) { if (!ExpressionUtil.IsEntityPropertyType(item.PropertyType)) { continue; ////是否.Net自带的String、DateTime,如果不是则跳过 //if (!((item.PropertyType.FullName == "System.String" || item.PropertyType.FullName == "System.DateTime") && item.PropertyType.Assembly.GlobalAssemblyCache)) //{ // continue; //} ////是否可空,如果不是则跳过 //var type = Nullable.GetUnderlyingType(item.PropertyType); //if (type == null) //{ // continue; //} } _columnInfos.Add(item.Name, new KeyValuePair <string, string>(_masterTableName, item.Name)); } return(node); }