コード例 #1
0
 private CriteriaToStringVisitResult ConvertCastFunction(FunctionOperator theOperator, Type type)
 {
     CriteriaToStringVisitResult result = null;
     if (theOperator.Operands.Count >= 1)
     {
         result = new CriteriaToStringVisitResult(String.Format("Cast({0} as {1})", Process(theOperator.Operands[0]).Result, type.FullName));
     }
     return result;
 }
コード例 #2
0
 public override Object Visit(AggregateOperand operand)
 {
     Object result = null;
     if (operand.AggregateType == Aggregate.Count)
     {
         if (Object.ReferenceEquals(operand.CollectionProperty, null))
         {
             result = new CriteriaToStringVisitResult("Count(0)");
         }
         else
         {
             result = new CriteriaToStringVisitResult(String.Format("Count(select value 1 from {0})", Process(operand.CollectionProperty).Result));
         }
     }
     else if (operand.AggregateType == Aggregate.Sum)
     {
         if (Object.ReferenceEquals(operand.CollectionProperty, null))
         {
             result = new CriteriaToStringVisitResult(String.Format("Sum({0})", Process(operand.AggregatedExpression).Result));
         }
         else
         {
             String collectionTableName = operand.CollectionProperty.PropertyName;
             Xpand.ExpressApp.NH.DataLayer.CriteriaToHqlConverter criteriaToEFSqlConverter = new Xpand.ExpressApp.NH.DataLayer.CriteriaToHqlConverter(collectionTableName, GetListElementType(operand.CollectionProperty.PropertyName));
             result = new CriteriaToStringVisitResult(String.Format("Sum(select value {0} from {1} as {2})",
                 criteriaToEFSqlConverter.Convert(operand.AggregatedExpression),
                 Process(operand.CollectionProperty).Result,
                 collectionTableName));
         }
     }
     else if (operand.AggregateType == Aggregate.Exists)
     {
         String collectionTableName = operand.CollectionProperty.PropertyName;
         Xpand.ExpressApp.NH.DataLayer.CriteriaToHqlConverter criteriaToEFSqlConverter = new Xpand.ExpressApp.NH.DataLayer.CriteriaToHqlConverter(collectionTableName, GetListElementType(operand.CollectionProperty.PropertyName));
         result = new CriteriaToStringVisitResult(String.Format("Exists(from {0} as {1} where {2})",
             Process(operand.CollectionProperty).Result,
             collectionTableName,
             criteriaToEFSqlConverter.Convert(operand.Condition)));
     }
     else
     {
         String resultString = ((CriteriaToStringVisitResult)base.Visit(operand)).Result;
         result = new CriteriaToStringVisitResult(resultString.TrimStart('[', ']', '.'));
     }
     return result;
 }