public T[] RunPrimetivSelect <T>(string query, dynamic parameters)
        {
            IEnumerable <IQueryParameter> enumarateFromDynamics = DbAccessLayerHelper.EnumarateFromDynamics(parameters);
            var runPrimetivSelect = RunPrimetivSelect(typeof(T), query, enumarateFromDynamics);

            return(runPrimetivSelect.Cast <T>().ToArray());
        }
        public object[] SelectWhere(Type type, string where, dynamic paramenter)
        {
            //Concret declaration is nessesary because we are working with dynmaics, so the compiler has ne space to guess the type wrong
            IEnumerable <IQueryParameter> enumarateFromDynamics = DbAccessLayerHelper.EnumarateFromDynamics(paramenter);

            return(SelectWhere(type, where, enumarateFromDynamics));
        }
        /// <summary>
        ///     Adds Parameter to the QueryCommand object without adding a Statement
        /// </summary>
        /// <returns></returns>
        public static TQuery WithParamerters <TQuery>(this TQuery query, dynamic paramerters)
            where TQuery : class, IQueryBuilder
        {
            IEnumerable <IQueryParameter> parameters = DbAccessLayerHelper.EnumarateFromDynamics(paramerters);

            return(query.QueryQ(string.Empty, parameters.ToArray()));
        }
        /// <summary>
        ///     Runs
        ///     <paramref name="command" />
        ///     and parses output into
        ///     <paramref name="type" />
        /// </summary>
        /// <returns></returns>
        public async Task <object[]> SelectNativeAsync(Type type, IDbCommand command, dynamic paramenter)
        {
            IEnumerable <IQueryParameter> enumarateFromDynamics = DbAccessLayerHelper.EnumarateFromDynamics(paramenter);

            foreach (var enumarateFromDynamic in enumarateFromDynamics)
            {
                command.Parameters.AddWithValue(enumarateFromDynamic.Name, enumarateFromDynamic.Value, Database);
            }

            return(await RunSelectAsync(type, command));
        }
        /// <summary>
        ///     Adds a QueryCommand part to <paramref name="builder" />
        /// </summary>
        /// <returns></returns>
        public static TQuery QueryD <TQuery>(this TQuery builder, string query, dynamic paramerters)
            where TQuery : class, IQueryBuilder
        {
            if (paramerters != null)
            {
                IEnumerable <IQueryParameter> parameters = DbAccessLayerHelper.EnumarateFromDynamics(paramerters);
                return(builder.Add(new GenericQueryPart(query, parameters, builder)));
            }

            return(builder.Add(new GenericQueryPart(query)));
        }
Пример #6
0
        /// <summary>
        ///     Wraps a QueryCommand and its Paramters from Dynamic and then executes it
        /// </summary>
        /// <returns></returns>
        public int ExecuteGenericCommand(string query, dynamic paramenter)
        {
            var parameters = paramenter as IEnumerable <IQueryParameter>;

            if (parameters != null)
            {
                var parm = parameters;
                return(ExecuteGenericCommand(query, parm));
            }

            return(ExecuteGenericCommand(query,
                                         (IEnumerable <IQueryParameter>)DbAccessLayerHelper.EnumarateFromDynamics(paramenter)));
        }
        /// <summary>
        ///     Runs
        ///     <paramref name="query" />
        ///     and parses output into
        ///     <paramref name="type" />
        /// </summary>
        /// <returns></returns>
        public async Task <object[]> SelectNativeAsync(Type type, string query, dynamic paramenter)
        {
            IEnumerable <IQueryParameter> enumarateFromDynamics = DbAccessLayerHelper.EnumarateFromDynamics(paramenter);

            return(await SelectNativeAsync(type, query, enumarateFromDynamics));
        }