protected void InitializeAggregates(INodeSchema schema, IDictionary <string, Type> parameterTypes) { foreach (var aggregate in Aggregates.Where(agg => agg.Value.SqlExpression != null)) { var sourceExpression = aggregate.Value.SqlExpression; // Sum and Average need to have Decimal values as input for their calculations to work correctly if (aggregate.Value.AggregateType == AggregateType.Average || aggregate.Value.AggregateType == AggregateType.Sum) { sourceExpression = new ConvertCall { Parameter = sourceExpression, DataType = new SqlDataTypeReference { SqlDataTypeOption = SqlDataTypeOption.Decimal } } } ; aggregate.Value.Expression = sourceExpression.Compile(schema, parameterTypes); aggregate.Value.ReturnType = aggregate.Value.SqlExpression.GetType(schema, null, parameterTypes); if (aggregate.Value.AggregateType == AggregateType.Average) { if (aggregate.Value.ReturnType == typeof(SqlByte) || aggregate.Value.ReturnType == typeof(SqlInt16)) { aggregate.Value.ReturnType = typeof(SqlInt32); } } } }
private void PrintSelectScalarExperssionRecurse(int aSelectElementID, ScalarExpression aScalarExpression) { if (aScalarExpression.GetType() == typeof(ColumnReferenceExpression)) { ColumnReferenceExpression aColumnReferenceExpression = (ColumnReferenceExpression)aScalarExpression; AddLogText(string.Format("ColumnType={0}", aColumnReferenceExpression.ColumnType.ToString())); MultiPartIdentifier aMultiPartIdentifier = aColumnReferenceExpression.MultiPartIdentifier; AddLogText(string.Format("Reference Identifier={0}", MultiPartIdentifierToString(aSelectElementID, aMultiPartIdentifier))); } else if (aScalarExpression.GetType() == typeof(ConvertCall)) { ConvertCall aConvertCall = (ConvertCall)aScalarExpression; ScalarExpression aScalarExpressionParameter = aConvertCall.Parameter; PrintSelectScalarExperssionRecurse(aSelectElementID, aScalarExpressionParameter); } else { AddLogText(String.Format("Not supported Expression:{0}", aScalarExpression.GetType().ToString())); } }
public override void Visit(ConvertCall node) { this.action(node); }
public override void ExplicitVisit(ConvertCall node) { base.ExplicitVisit(node); ReplaceExpression(node, n => n.Parameter); }
public override void ExplicitVisit(ConvertCall fragment) { _fragments.Add(fragment); }
public override void Visit(ConvertCall node) { FindColumnReferences(node); }
public override void Visit(ConvertCall node) { VisitChildren(node); }