src/Inflatable/QueryProvider/Providers/SQLServer/QueryGenerators/LinqQueryGenerator.cs
/// <summary>
/// Generates the order by clause.
/// </summary>
/// <param name="node">The node.</param>
/// <param name="data">The data.</param>
/// <returns>Order by clause</returns>
Generates the order by clause.
Generates the order by clause .
private string GenerateOrderByClause(Utils.TreeNode<Type> node, QueryData<TMappedClass> data)
        {
            var Builder = ObjectPool.Get();
            var Splitter = string.Empty;
            string ReturnValue = string.Empty;
            if (data.OrderByValues.Count == 0)
            {
                var Mapping = MappingInformation.Mappings[node.Data];
                for (int x = 0, nodeNodesCount = node.Nodes.Count; x < nodeNodesCount; x++)
                {
                    var ParentNode = node.Nodes[x];
                    var ParentResult = GenerateOrderByClause(ParentNode, data);
                    if (!string.IsNullOrEmpty(ParentResult))
                        return ParentResult;
                }
                foreach (var IDProperty in Mapping.IDProperties)
                {
                    Builder.Append(Splitter)
                       .Append(GetColumnName(IDProperty));
                    Splitter = ",";
                }
                ReturnValue = Builder.ToString();
                ObjectPool.Return(Builder);
                return ReturnValue;
            }
            foreach (var Column in data.OrderByValues.OrderBy(x => x.Order))
            {
                Builder.Append(Splitter)
                       .Append(Column.Property.Name)
                       .Append(Column.Direction == Direction.Descending ? " DESC" : "");
                Splitter = ",";
            }
            ReturnValue = Builder.ToString();
            ObjectPool.Return(Builder);
            return ReturnValue;
        }
private string GenerateOrderByClause ( Utils . TreeNode < Type > node , QueryData < TMappedClass > data ) { var Builder = ObjectPool . Get ( ) ; var Splitter = string . Empty ; string ReturnValue = string . Empty ; if ( data . OrderByValues . Count == 0 ) { var Mapping = MappingInformation . Mappings [ node . Data ] ; for ( int x = 0 , nodeNodesCount = node . Nodes . Count ; x < nodeNodesCount ; x ++ ) { var ParentNode = node . Nodes [ x ] ; var ParentResult = GenerateOrderByClause ( ParentNode , data ) ; if ( ! string . IsNullOrEmpty ( ParentResult ) ) return ParentResult ; } foreach ( var IDProperty in Mapping . IDProperties ) { Builder . Append ( Splitter ) . Append ( GetColumnName ( IDProperty ) ) ; Splitter = " " ; } ReturnValue = Builder . ToString ( ) ; ObjectPool . Return ( Builder ) ; return ReturnValue ; } foreach ( var Column in data . OrderByValues . OrderBy ( x => x . Order ) ) { Builder . Append ( Splitter ) . Append ( Column . Property . Name ) . Append ( Column . Direction == Direction . Descending ? " " : " " ) ; Splitter = " " ; } ReturnValue = Builder . ToString ( ) ; ObjectPool . Return ( Builder ) ; return ReturnValue ; }
Generates the order by clause.
Generates the order by clause .
Order by clause
Order by clause
node
Utils.TreeNode<Type>
None
data
QueryData<TMappedClass>
None