コード例 #1
0
ファイル: DbSessionTests.cs プロジェクト: xydoublez/RDO.Net
        private static void GetDistinctSalesOrderDetails(Db db, DbAggregateQueryBuilder queryBuilder, SalesOrderDetail model)
        {
            SalesOrderDetail d;

            queryBuilder.From(db.SalesOrderDetail, out d)
            .AutoSelect()
            .OrderBy(d.SalesOrderDetailID);
        }
コード例 #2
0
ファイル: DbQuery.cs プロジェクト: aTiKhan/RDO.Net
        /// <summary>
        /// Creates child query from aggregate query builder.
        /// </summary>
        /// <typeparam name="TChild">Type of child model.</typeparam>
        /// <param name="initializer">The child model initializer.</param>
        /// <param name="getChildModel">The delegate to get child model.</param>
        /// <param name="buildQuery">The aggregate query builder.</param>
        /// <param name="ct">The async cancellation token.</param>
        /// <returns>The child query.</returns>
        public async Task <DbQuery <TChild> > CreateChildAsync <TChild>(Action <TChild> initializer, Func <T, TChild> getChildModel, Action <DbAggregateQueryBuilder, TChild> buildQuery, CancellationToken ct = default(CancellationToken))
            where TChild : Model, new()
        {
            buildQuery.VerifyNotNull(nameof(buildQuery));
            var childModel = VerifyCreateChild(initializer, getChildModel);

            await EnsureSequentialTempTableCreatedAsync(DbSession, ct);

            if (SequentialKeyTempTable.InitialRowCount == 0)
            {
                return(null);
            }
            var queryBuilder = new DbAggregateQueryBuilder(childModel);

            buildQuery(queryBuilder, childModel);
            return(DbSession.PerformCreateQuery(childModel, queryBuilder.BuildQueryStatement(null)));
        }