MssqlEntityQuery<TRow, TFields, S extends MssqlEntityQuery<TRow, TFields, S> > class
abstract
Abstract base for generated table queries, preserving the concrete query type through every entity-preserving call.
S is the generated self type (OrdersQuery extends MssqlEntityQuery<Order, OrdersFields, OrdersQuery>), so where, orderBy, withTrashed and every
other narrowing method return S rather than a widened base. IDE
completion sees the real type after each call, and a user extension
(extension OrderScopes on OrdersQuery) stays in the pipeline.
Generated code supplies the binding, the fields instance, whereX
equality shortcuts, and the rebuild that returns S. Terminals here
delegate to the same session and mapper the repository uses — a second
executor would drift.
Constructors
-
MssqlEntityQuery(MssqlQueryContext<
TRow> context, [MssqlQueryState state = const MssqlQueryState.empty(), List<MssqlRelation< included = const []])TRow, Object?> >
Properties
-
binding
→ MssqlTableBinding<
TRow> -
The table binding shared with the repository.
no setter
-
context
→ MssqlQueryContext<
TRow> -
The execution context: session, binding, dialect, clock.
final
- dialect → MssqlDialect
-
The dialect this query compiles against.
no setter
- fields → TFields
-
Typed SQL columns for callbacks, not a row and not a string lookup.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
included
→ List<
MssqlRelation< TRow, Object?> > -
Relations this query will load after the parent rows, in call order.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scopeSelection → MssqlScopeSelection
-
The scope selection this query currently carries.
no setter
- session → MssqlSession
-
The session shared with the repository.
no setter
- state → MssqlQueryState
-
The immutable query state: scope selection, predicates, ordering.
final
Methods
-
at(
{String? schema, String? table}) → S - This query over another schema or table name.
-
attachIncludes(
List< TRow> parents) → Future<List< TRow> > -
Loads this query's includes onto already-fetched
parents. -
chunk(
{int size = 500}) → Stream< List< TRow> > -
Walks matching rows in keyset pages of
size, not OFFSET. -
chunkById(
{int size = 500}) → Stream< List< TRow> > -
Keyset chunk ordered by the primary key, or by the caller's unique
orderByon a keyless table. -
compile(
{MssqlDialect? dialect}) → MssqlStatement - The SQL and parameters this query would run, without running it.
-
count(
) → Future< int> - How many rows this query currently matches.
-
createGraphValues(
MssqlGraphInsert< TRow> graph, {MssqlCycleWrite cycle = MssqlCycleWrite.refuse}) → Future<TRow> -
Explicit graph insert of
graphin one transaction. -
createManyValues(
List< MssqlWriteAssignments> rows, {MssqlCreateManyStrategy strategy = MssqlCreateManyStrategy.insertValues, MssqlBulkOptions bulk = const MssqlBulkOptions(), bool atomic = true, bool returnRows = true}) → Future<MssqlCreateManyResult< TRow> > -
Batched insert of
rows. Atomic by default; never switches to BCP. -
createValues(
MssqlWriteAssignments values) → Future< TRow> -
Inserts
valuesand returns the stored row. -
cursorPage(
{int size = 25, MssqlCursor? after, MssqlCursor? before, MssqlReadConsistency consistency = MssqlReadConsistency.committed}) → Future< MssqlCursorPage< TRow> > -
A keyset page.
afterandbeforeare mutually exclusive. -
decrementQuantities(
{required String keyColumn, required String quantityColumn, required Iterable< ({num amount, Object key})> requests}) → Future<int> -
Groups
requestsbykeyColumnand subtracts in one guarded UPDATE. -
dropPageSentinel(
List< TRow> fetched, int pageSize) → List<TRow> -
Drops the extra row a page fetched to learn
hasMore, before include. -
ensureStableOrder(
) → S -
page/chunk/cursorPage: used when the caller gave none, and as a tie-breaker when they gave some. -
first(
) → Future< TRow?> - The first matching row in the requested order, or null.
-
firstOrFail(
) → Future< TRow> - The first matching row, or MssqlRowNotFoundException.
-
get(
) → Future< List< TRow> > - Every matching row. There is no hidden limit.
-
getOrCreate(
{required MssqlUniqueMatch key, required MssqlWriteAssignments create, bool restoreExisting = false, bool includeDeleted = false}) → Future< TRow> -
Inserts
create, or returns the live row that already ownskey. -
include(
Iterable< MssqlRelation< relations(TFields fields)) → STRow, Object?> > -
Loads
relationsafter the parent rows, merging same paths. -
lazy(
{int size = 500}) → Stream< TRow> - chunkById as a row stream.
-
loadMissing(
List< TRow> rows, Iterable<MssqlRelation< relations(TFields fields)) → Future<TRow, Object?> >List< TRow> > -
Loads
relationsontorowsthat were fetched without them. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onlyTrashed(
) → S -
options(
MssqlQueryOptions options) → S - Replaces the native execution options.
-
orderBy(
List< MssqlOrder> ordering(TFields fields)) → S - Replaces the ordering from a fields callback.
-
page(
{int size = 25, int offset = 0, bool total = false, MssqlReadConsistency consistency = MssqlReadConsistency.committed}) → Future< MssqlPage< TRow> > - One OFFSET page, and whether another follows.
-
rebuild(
MssqlQueryState state) → S -
Rebuilds this query with new state, returning the same type
S. -
recreate(
MssqlQueryState state, List< MssqlRelation< included) → STRow, Object?> > -
Generated:
OrdersQuery(context, state, included). -
recreateAt(
MssqlQueryContext< TRow> context, MssqlQueryState state, List<MssqlRelation< included) → STRow, Object?> > -
Generated:
OrdersQuery(context, state, included)over anothercontext. -
Writes against one relation of
parent. -
search(
String? term, List< MssqlTextExpression> columns(TFields fields), {MssqlLikePosition position = MssqlLikePosition.anywhere}) → S -
Adds a text search over
columnswhentermhas a non-whitespace character. -
select<
R> (MssqlProjection< R> projection) → MssqlProjectedQuery<R> -
Projects this query through
projection, dropping entity writes. -
select2<
A, B> ((MssqlExpression, MssqlExpression) select(TFields fields)) → MssqlProjectedQuery< (A, B)> -
Two typed columns as a Dart record
(A, B). -
select3<
A, B, C> ((MssqlExpression, MssqlExpression, MssqlExpression) select(TFields fields)) → MssqlProjectedQuery< (A, B, C)> -
Three typed columns as a Dart record
(A, B, C). -
select4<
A, B, C, D> ((MssqlExpression, MssqlExpression, MssqlExpression, MssqlExpression) select(TFields fields)) → MssqlProjectedQuery< (A, B, C, D)> -
Four typed columns as a Dart record
(A, B, C, D). -
single(
) → Future< TRow> - Exactly one matching row.
-
singleOrNull(
) → Future< TRow?> - At most one matching row, or null when none match.
-
stream(
{int parentBatch = 100}) → Stream< TRow> - Maps the native row stream. Does not buffer the whole result.
-
thenBy(
List< MssqlOrder> ordering(TFields fields)) → S - Appends ordering, keeping what is already there.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateManyKeyed(
List< MssqlKeyedPatch> patches, {int? expectAffected}) → Future<int> -
Staging JOIN update of
patchesby their keys. -
updateValues(
MssqlWriteAssignments patch, {Object? expectedVersion, int? expectAffected}) → Future< int> -
Writes
patchto every row this query currently matches. -
watch(
{MssqlWatchStrategy strategy = MssqlWatchStrategy.localWrites, Duration interval = const Duration(seconds: 1), Iterable< String> ? tables}) → Stream<List< TRow> > - Re-runs this query when its tables may have changed.
-
when(
bool test, S build(S query)) → S -
Rebuilds this query through
buildonly whentestis true. -
where(
MssqlCondition predicate(TFields fields)) → S - Adds a predicate built from fields, ANDed with those already present.
-
whereDoesntHave<
TChild> (MssqlRelation< TRow, TChild> relation(TFields fields)) → S - Keeps parents that have no matching related row.
-
whereHas<
TChild> (MssqlRelation< TRow, TChild> relation(TFields fields)) → S - Keeps parents that have at least one matching related row.
-
whereIf(
bool test, MssqlCondition predicate(TFields fields)) → S -
Adds
predicateonly whentestis true. -
whereIfNotNull<
V> (V? value, MssqlCondition predicate(TFields fields, V value)) → S -
Adds
predicateonly whenvalueis not null. -
whereInIfNotEmpty<
V> (Iterable< V> values, MssqlCondition predicate(TFields fields, List<V> values)) → S -
Adds
predicateonly whenvaluesis not empty. -
withAggregates(
List< MssqlRelationAggregate< aggregates(TFields fields)) → MssqlProjectedQuery<TRow> >(TRow, Map< String, Object?> )> - Several independent correlated aggregates on one parent SELECT.
-
withAvgExact<
TChild> (MssqlRelation< TRow, TChild> relation(TFields fields), MssqlExpression operand, {int exactScale = 6}) → MssqlProjectedQuery<(TRow, MssqlDecimal?)> -
Parent rows plus an exact
AVGofoperandon matching children. -
withAvgTruncating<
TChild, V> (MssqlRelation< TRow, TChild> relation(TFields fields), MssqlExpression operand) → MssqlProjectedQuery<(TRow, V?)> -
Parent rows plus
AVGofoperandwith SQL Server's own integer rule kept: the remainder of an integer column is discarded. -
withCount<
TChild> (MssqlRelation< TRow, TChild> relation(TFields fields), {bool big = true}) → MssqlProjectedQuery<(TRow, int)> - Parent rows plus a count of matching children, as a projection.
-
withExists<
TChild> (MssqlRelation< TRow, TChild> relation(TFields fields)) → MssqlProjectedQuery<(TRow, bool)> -
Parent rows plus whether any matching child exists, as a
bit. -
withMax<
TChild, V> (MssqlRelation< TRow, TChild> relation(TFields fields), MssqlExpression operand) → MssqlProjectedQuery<(TRow, V?)> -
Parent rows plus
MAXofoperandon matching children. -
withMin<
TChild, V> (MssqlRelation< TRow, TChild> relation(TFields fields), MssqlExpression operand) → MssqlProjectedQuery<(TRow, V?)> -
Parent rows plus
MINofoperandon matching children. -
withoutGlobalScopes(
) → S -
withoutScope(
String name) → S -
withoutTrashed(
) → S -
withSum<
TChild, V> (MssqlRelation< TRow, TChild> relation(TFields fields), MssqlExpression operand) → MssqlProjectedQuery<(TRow, V?)> -
Parent rows plus
SUMofoperandon matching children. -
withTrashed(
) → S -
withTypedCte(
MssqlTypedCte cte) → S -
Declares
cteon this query's statement. -
withWhereHas<
TChild> (MssqlRelation< TRow, TChild> relation(TFields fields)) → S -
whereHasandincludeof the same handle, so the loaded children are the ones the filter named.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited