public override int AddToProjection(IProperty property, IQuerySource querySource) { if (TypeValidator.IsValidat(property.Name) == false) { return(-999); } return(base.AddToProjection(property, querySource)); }
public override Expression Visit(Expression node) { if (node == null) { return(node); } var targetExpression = QueryModelVisitor.QueryCompilationContext.QuerySourceMapping .GetExpression(_querySource); if (targetExpression.Type == typeof(ValueBuffer) && !CheckedMember(node as MemberExpression)) { return(node); } var result = base.Visit(node); if (result.NodeType == ExpressionType.Convert) { var convert = result as UnaryExpression; var pas = convert.Operand as MethodCallExpression; var parmeter = pas.Arguments.ToArray()[0] as ConstantExpression; if (parmeter.Type == typeof(int) && object.Equals(parmeter.Value, -999)) { parmeter = Expression.Constant(0); var gentMethod = convertMethod.MakeGenericMethod(convert.Type, parmeter.Type); pas = Expression.Call(gentMethod, parmeter); result = Expression.Convert(pas, convert.Type); } return(result); } switch (node) { case MemberExpression column: if (TypeValidator.IsValidat(column.Member.Name) == false) { var select = column.Expression as QuerySourceReferenceExpression; var type = select.ReferencedQuerySource.ItemType; for (int i = 0; i < Projection.Count; i++) { var col = Projection[i] as ColumnExpression; if (col.Name == column.Member.Name) { Projection.RemoveAt(i); } } } break; default: break; } //var column = node as MemberExpression; //if (column != null && TypeValidator.IsValidat(column.Member.Name) == false) //{ // var select = column.Expression as QuerySourceReferenceExpression; // var type = select.ReferencedQuerySource.ItemType; // for (int i = 0; i < Projection.Count; i++) // { // var col = Projection[i] as ColumnExpression; // if (col.Name == column.Member.Name) // { // Projection.RemoveAt(i); // } // } //} return(result); }
private bool CheckedMember(MemberExpression column) { var result = column != null && TypeValidator.IsValidat(column.Member.Name) == false; return(result); }