コード例 #1
0
        /// <inheritdoc />
        public IEnumerable <TViewData> Execute <TDataFilter>(IDataFilter <TDataFilter, TData> filter, IDbConnection connection) where TDataFilter : IDataFilter <TDataFilter, TData>
        {
            if (!_compiled)
            {
                Compile();
            }

            var parameters     = new Dictionary <string, object>();
            var transaction    = default(IDbTransaction);
            var buffered       = true;
            int?commandTimeout = null;

            var filterPredicate = _predicateFactory.GetPredicate <TDataFilter, TData>(filter);

            var filterSql = _predicateQueryBuilderFactory
                            .GetQueryBuilder(filterPredicate, this)
                            .GetSql(filterPredicate, parameters);

            var dynamicParameters = new DynamicParameters();

            foreach (var parameter in parameters)
            {
                dynamicParameters.Add(parameter.Key, parameter.Value);
            }

            return(connection.Query <TViewData>($"{_query} WHERE {filterSql}", dynamicParameters, transaction, buffered, commandTimeout, CommandType.Text));
        }
コード例 #2
0
ファイル: Gateway.cs プロジェクト: InterestIT/FluentDapper
        /// <inheritdoc />
        public async Task <IEnumerable <TData> > Get(TDataFilter filter)
        {
            var filterPredicate = _predicateFactory.GetPredicate <TDataFilter, TData>(filter);
            var dataItems       = await _connectionFactory.GetConnection().GetListAsync <TData>(filterPredicate);

            return(dataItems?.ToList());
        }