コード例 #1
0
        private static IAsyncEnumerable <T> SelectAsync <T, T1, T2, T3, T4>(Expression <Func <T, T1, bool> > join1, Expression <Func <T1, T2, bool> > join2, Expression <Func <T2, T3, bool> > join3, Expression <Func <T3, T4, bool> > join4,
                                                                            Expression <Func <T, bool> > predicate = null, string connectionName = null, DbConnection connection = null, DialectProvider provider = null, int page = 0, int pageSize = 0, int skipCount = 0, bool?cached = null,
                                                                            SelectOption selectOption = SelectOption.All, IConfiguration config  = null, params Sorting <T>[] orderBy)
            where T : class
            where T1 : class
            where T2 : class
            where T3 : class
            where T4 : class
        {
            if (provider == null)
            {
                string providerName = null;
                if (connection == null)
                {
                    providerName = DbFactory.GetProviderInvariantName(connectionName, typeof(T), config);
                    connection   = DbFactory.CreateConnection(connectionName, typeof(T), config);
                }

                provider = DialectFactory.GetProvider(connection, providerName);
            }

            var sqlRoot  = SqlBuilder.GetSelectStatement(predicate, page, pageSize, skipCount, selectOption != SelectOption.All, provider, orderBy);
            var sqlJoin1 = SqlBuilder.GetSelectStatement(predicate, join1, 0, 0, 0, false, provider, orderBy);
            var sqlJoin2 = SqlBuilder.GetSelectStatement(predicate, join1, join2, 0, 0, 0, false, provider, orderBy);
            var sqlJoin3 = SqlBuilder.GetSelectStatement(predicate, join1, join2, join3, 0, 0, 0, false, provider, orderBy);
            var sqlJoin4 = SqlBuilder.GetSelectStatement(predicate, join1, join2, join3, join4, 0, 0, 0, false, provider, orderBy);

            var result = new EagerLoadEnumerableAsync <T>(new[] { sqlRoot, sqlJoin1, sqlJoin2, sqlJoin3, sqlJoin4 }, new[] { typeof(T), typeof(T1), typeof(T2), typeof(T3), typeof(T4) },
                                                          async(s, t) => ((IMultiResult)await RetrieveImplemenationAsync <T>(s, OperationType.Sql, null, OperationReturnType.MultiResult, connectionName, connection, types: t, cached: cached, config: config).ConfigureAwait(false)).Aggregate <T>(config), predicate, provider, selectOption, connectionName, connection, page, pageSize, skipCount, config);

            return(result);
        }
コード例 #2
0
ファイル: ObjectFactoryAsync.cs プロジェクト: tahiralvi/Nemo
        private static IAsyncEnumerable <T> SelectAsync <T, T1>(Expression <Func <T, T1, bool> > join, Expression <Func <T, bool> > predicate = null, string connectionName = null, DbConnection connection = null, DialectProvider provider = null, int page = 0, int pageSize = 0,
                                                                bool?cached = null, SelectOption selectOption = SelectOption.All, params Sorting <T>[] orderBy)
            where T : class
            where T1 : class
        {
            if (provider == null)
            {
                string providerName = null;
                if (connection == null)
                {
                    providerName = DbFactory.GetProviderInvariantName(connectionName, typeof(T));
                    connection   = DbFactory.CreateConnection(connectionName, typeof(T));
                }

                provider = DialectFactory.GetProvider(connection, providerName);
            }

            var sqlRoot = SqlBuilder.GetSelectStatement(predicate, page, pageSize, selectOption != SelectOption.All, provider, orderBy);
            var sqlJoin = SqlBuilder.GetSelectStatement(predicate, join, 0, 0, false, provider, orderBy);

            var result = new EagerLoadEnumerableAsync <T>(new[] { sqlRoot, sqlJoin }, new[] { typeof(T), typeof(T1) },
                                                          (s, t) => RetrieveImplemenationAsync <T>(s, OperationType.Sql, null, OperationReturnType.MultiResult, connectionName, connection, types: t, cached: cached), predicate, provider, selectOption);

            return(result);
        }
コード例 #3
0
        public static IAsyncEnumerable <T> SelectAsync <T>(Expression <Func <T, bool> > predicate = null, string connectionName = null, DbConnection connection = null, int page = 0, int pageSize = 0, int skipCount = 0, bool?cached = null,
                                                           SelectOption selectOption = SelectOption.All, IConfiguration config  = null, params Sorting <T>[] orderBy)
            where T : class
        {
            string providerName = null;

            if (connection == null)
            {
                providerName = DbFactory.GetProviderInvariantName(connectionName, typeof(T), config);
                connection   = DbFactory.CreateConnection(connectionName, typeof(T), config);
            }

            var provider = DialectFactory.GetProvider(connection, providerName);

            var sql = SqlBuilder.GetSelectStatement(predicate, page, pageSize, skipCount, selectOption != SelectOption.All, provider, orderBy);

            var result = new EagerLoadEnumerableAsync <T>(new[] { sql }, new[] { typeof(T) },
                                                          (s, t) => RetrieveImplemenationAsync <T>(s, OperationType.Sql, null, OperationReturnType.SingleResult, connectionName, connection, types: t, cached: cached, config: config), predicate, provider, selectOption, connectionName, connection, page, pageSize, skipCount, config);

            return(result);
        }