예제 #1
0
        private void AppendOrderByKey(StringBuilder orderByClauseBuilder, string expression, string errorText, TypeUsage tu)
        {
            if (!String.IsNullOrEmpty(expression))
            {
                string[] statements = expression.Split(',');

                string spacer = String.Empty;
                foreach (string statement in statements)
                {
                    bool   isAscending = true;
                    string columnName  = ParseStatement(statement.Trim(), out isAscending);

                    if (String.IsNullOrEmpty(columnName))
                    {
                        throw new ArgumentException(Strings.EntityDataSourceView_EmptyPropertyName);
                    }

                    if (EntityDataSourceUtil.PropertyIsOnEntity(columnName, _wrapperCollection, null, tu))
                    {
                        orderByClauseBuilder.Append(spacer);
                        orderByClauseBuilder.Append(EntityDataSourceUtil.GetEntitySqlValueForColumnName(columnName, _wrapperCollection));
                    }
                    else // pass the sort expression through verbatim.
                    {
                        if (!columnName.StartsWith("it.", StringComparison.OrdinalIgnoreCase))
                        {
                            columnName = "it." + columnName;
                        }
                        orderByClauseBuilder.Append(spacer + columnName);
                    }

                    if (!isAscending)
                    {
                        orderByClauseBuilder.Append(c_esqlDescendingTail);
                    }

                    spacer = ",";
                }
            }
        }