Beispiel #1
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="dataStrategy">The data strategy.</param>
        /// <param name="table"></param>
        /// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
        /// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
        /// <returns></returns>
        public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
        {
            var query = new SimpleQuery(dataStrategy.GetAdapter(), table.GetQualifiedName());

            if (args.Length == 1 && args[0] is SimpleExpression)
            {
                query = query.Where((SimpleExpression)args[0]);
            }

            return(query.Count());
        }
Beispiel #2
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="dataStrategy">The data strategy.</param>
        /// <param name="table"></param>
        /// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
        /// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
        /// <returns></returns>
        public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
        {
            var query = new SimpleQuery(dataStrategy, table.GetQualifiedName());

            if (args.Length == 1 && args[0] is SimpleExpression)
            {
                query = query.Where((SimpleExpression)args[0]);
            }

            return query.Count();
        }
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="dataStrategy">The data strategy.</param>
        /// <param name="table"></param>
        /// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
        /// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
        /// <returns></returns>
        public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
        {
            var query = new SimpleQuery(dataStrategy, table.GetQualifiedName());

            if (args.Length == 1)
            {
                var expression = args[0] as SimpleExpression;
                if (expression != null)
                {
                    return query.Where(expression).Count();
                }
                else
                {
                    throw new BadExpressionException("GetCount expects an expression or no parameters.");
                }
            }
            else if (args.Length == 0)
            {
                return query.Count();
            }

            throw new ArgumentException("GetCount expects an expression or no parameters.");
        }
Beispiel #4
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="dataStrategy">The data strategy.</param>
        /// <param name="table"></param>
        /// <param name="binder">The binder from the <see cref="DynamicTable"/> method invocation.</param>
        /// <param name="args">The arguments from the <see cref="DynamicTable"/> method invocation.</param>
        /// <returns></returns>
        public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
        {
            var query = new SimpleQuery(dataStrategy, table.GetQualifiedName());

            if (args.Length == 1)
            {
                var expression = args[0] as SimpleExpression;
                if (expression != null)
                {
                    return(query.Where(expression).Count());
                }
                else
                {
                    throw new BadExpressionException("GetCount expects an expression or no parameters.");
                }
            }
            else if (args.Length == 0)
            {
                return(query.Count());
            }

            throw new ArgumentException("GetCount expects an expression or no parameters.");
        }