Beispiel #1
0
        private static void GetSalesOrderDetails(Db db, DbQueryBuilder queryBuilder, SalesOrderDetail model)
        {
            SalesOrderDetail d;

            queryBuilder.From(db.SalesOrderDetail, out d)
            .AutoSelect()
            .OrderBy(d.SalesOrderDetailID);
        }
Beispiel #2
0
        /// <summary>
        /// Creates child query from 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 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 <DbQueryBuilder, 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 DbQueryBuilder(childModel);

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