Ejemplo n.º 1
0
        public SqlExpressionVisitor(IDataSourceTagSpecific dataSourceTagSpecific, IUnitOfWorkContext unitOfWorkContext, IList<IDataParameter> commandParameters)
        {
            if ((object)dataSourceTagSpecific == null)
                throw new ArgumentNullException("dataSourceTagSpecific");

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)commandParameters == null)
                throw new ArgumentNullException("commandParameters");

            this.dataSourceTagSpecific = dataSourceTagSpecific;
            this.unitOfWorkContext = unitOfWorkContext;
            this.commandParameters = commandParameters;
        }
Ejemplo n.º 2
0
        public static string GetFilterText(IDataSourceTagSpecific dataSourceTagSpecific, IUnitOfWorkContext unitOfWorkContext, IList<IDataParameter> commandParameters, IExpression expression)
        {
            SqlExpressionVisitor expressionVisitor;
            string expressionText;

            if ((object)dataSourceTagSpecific == null)
                throw new ArgumentNullException("dataSourceTagSpecific");

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)commandParameters == null)
                throw new ArgumentNullException("commandParameters");

            if ((object)expression == null)
                throw new ArgumentNullException("expression");

            expressionVisitor = new SqlExpressionVisitor(dataSourceTagSpecific, unitOfWorkContext, commandParameters);
            expressionVisitor.Visit(expression);
            expressionText = expressionVisitor.Strings.ToString();

            return expressionText;
        }
Ejemplo n.º 3
0
        public static string GetSortText(IDataSourceTagSpecific dataSourceTagSpecific, IUnitOfWorkContext unitOfWorkContext, IList<IDataParameter> commandParameters, Order[] orders)
        {
            string expressionText;
            List<string> sortNames;

            if ((object)dataSourceTagSpecific == null)
                throw new ArgumentNullException("dataSourceTagSpecific");

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)commandParameters == null)
                throw new ArgumentNullException("commandParameters");

            if ((object)orders == null)
                throw new ArgumentNullException("orders");

            sortNames = new List<string>();

            if ((object)orders != null)
            {
                foreach (Order order in orders)
                {
                    if ((object)order.Facet == null)
                        continue;

                    sortNames.Add(string.Format("{0} {1}", dataSourceTagSpecific.GetAliasedColumnName("t0", order.Facet.Name), order.Ascending ? "ASC" : "DESC"));
                }
            }

            if (sortNames.Count <= 0)
                sortNames.Add("1");

            expressionText = string.Join(", ", sortNames.ToArray());

            return expressionText;
        }