예제 #1
0
        public virtual string CreateOrderByClause(QueryPartCollector queryPartCollector)
        {
            StringBuilder orderByClause = new StringBuilder();

            if (queryPartCollector != null && queryPartCollector.OrderPartKeys != null)
            {
                bool isFirstElement = true;
                foreach (object key in queryPartCollector.OrderPartKeys)
                {
                    if (isFirstElement)
                    {
                        isFirstElement = false;
                        orderByClause.Append(" order by ");
                    }
                    else
                    {
                        orderByClause.Append(" , ");
                    }

                    OrderBase orderPart = (OrderBase)queryDescriptor.OrderParts[key];
                    orderByClause.Append(orderPart.ToPhrase());
                    orderByClause.Append(" ");
                }
            }

            return(orderByClause.ToString());
        }
예제 #2
0
        public virtual string CreateWhereClause(QueryPartCollector queryPartCollector)
        {
            StringBuilder whereClause = new StringBuilder();

            if (queryPartCollector != null && queryPartCollector.CriterionValuePairs != null && queryDescriptor != null && queryDescriptor.CriterionParts != null)
            {
                bool isFirstElement = true;
                foreach (QueryPartCollector.CriterionValuePair criterionValuePair in queryPartCollector.CriterionValuePairs)
                {
                    CriterionBase criterionElement = (CriterionBase)queryDescriptor.CriterionParts[criterionValuePair.CriterionKey];

                    if (isFirstElement)
                    {
                        isFirstElement = false;
                        whereClause.Append(" where ");
                        whereClause.Append(criterionElement.ToPhrase(true));
                        whereClause.Append(" ");
                    }
                    else
                    {
                        whereClause.Append(" ");
                        whereClause.Append(criterionElement.ToPhrase());
                        whereClause.Append(" ");
                    }
                }
            }

            return(whereClause.ToString());
        }
예제 #3
0
        public virtual string CreateSelectClause(QueryPartCollector queryPartCollector)
        {
            StringBuilder selectClause = new StringBuilder();

            if (queryPartCollector != null && queryDescriptor != null && queryPartCollector.SelectPartKeys != null)
            {
                bool isFirstElement = true;
                foreach (object key in queryPartCollector.SelectPartKeys)
                {
                    if (isFirstElement)
                    {
                        isFirstElement = false;
                        selectClause.Append(" select ");
                    }
                    else
                    {
                        selectClause.Append(" , ");
                    }

                    SelectBase selectPart = (SelectBase)queryDescriptor.SelectParts[key];
                    selectClause.Append(selectPart.ToPhrase());
                    selectClause.Append(" ");
                }
            }

            return(selectClause.ToString());
        }
예제 #4
0
        public virtual string CreateFromClause(QueryPartCollector queryPartCollector)
        {
            StringBuilder fromClause = new StringBuilder();

            if (queryDescriptor != null && queryDescriptor.FromPart != null)
            {
                fromClause.Append(" from ");
                fromClause.Append(queryDescriptor.FromPart.ToPhrase());
                fromClause.Append(" ");
            }

            return(fromClause.ToString());
        }
예제 #5
0
        public void FillParameters(IQuery query, QueryPartCollector queryPartCollector)
        {
            IList <QueryPartCollector.CriterionValuePair> criterionValuePairs = queryPartCollector.CriterionValuePairs;
            IDictionary <Object, CriterionBase>           criterionParts      = queryDescriptor.CriterionParts;

            foreach (QueryPartCollector.CriterionValuePair criterionValuePair in criterionValuePairs)
            {
                CriterionBase criterionBase = (CriterionBase)criterionParts[criterionValuePair.CriterionKey];

                if (criterionBase.IsCriterionParameterRequired())
                {
                    if (criterionBase is ISingleParameterCriterion)
                    {
                        ISingleParameterCriterion singleParameterCriterion = (ISingleParameterCriterion)criterionBase;
                        string criterionParameterName = singleParameterCriterion.CriterionParameterName;
                        Type   criterionParameterType = singleParameterCriterion.CriterionParameterType;

                        FillParameter(query, criterionParameterName, criterionParameterType, GetCriterionValue(criterionBase, criterionValuePair));
                    }
                }
            }
        }
예제 #6
0
 public virtual string CreateHavingClause(QueryPartCollector queryPartCollector)
 {
     return(string.Empty);
 }