[C#] Removes Query<TRow> and .Build() in favor of IQuery<TRow>#4393
Merged
clockwork-labs-bot merged 3 commits intomasterfrom Feb 23, 2026
Merged
Conversation
1 task
Build() conversion to QueryBuild() conversion to AddQuery
Build() conversion to AddQueryBuild() conversion to Query
Build() conversion to QueryBuild() conversion to Query<TRow>
Build() conversion to Query<TRow>Query<TRow> and .Build() in favor of IQuery<TRow>
joshua-spacetime
approved these changes
Feb 23, 2026
This was referenced Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes an issue with the C# implementation of Query Builder requiring
Build()to return a query, and the return type beingQuery<TRow>rather thanIQuery<TRow>.Description of Changes
Query<TRow>carrier type and every.Build(). Query builder shapes now expose onlyIQuery<TRow>plusToSql().IQuery<TRow>.ViewDeclarationanalysis to treat any return type implementingSpacetimeDB.IQuery<TRow>as a SQL view.ViewResultHeader.RawSql(returnValue.ToSql()). This eliminates aQuery<TRow>special-case.ToSql()/returnIQuery<TRow>.RightSemiJoin(and friends) still satisfyIQuery<TRow>.SubscriptionBuilder.AddQueryacceptsFunc<QueryBuilder, IQuery<TRow>>and captures SQL viaToSql().API and ABI breaking changes
While technically API breaking, this actually brings the API closer to the intended design.
Query<TRow>has been removed from the public surface area; any previous references (including.Build()and.Sql) must be replaced with the builder instance itself plus.ToSql().IQuery<TRow>(or any custom type implementing it) when producing SQL for the host.IQuery<TRow>, aligning the client SDK with the new runtime contract.Expected complexity level and risk
3 - Medium: Touches runtime, codegen, fixtures, and templates. Risk is mitigated by parity with Rust semantics and comprehensive test updates, but downstream modules must recompile to adopt the new interface.
Testing
.Build()dotnet test .\sdks\csharp\tests~\tests.csproj -c Releasewith all tests passingdotnet test .\crates\bindings-csharp\Codegen.Tests\Codegen.Tests.csproj -c Releasewith all tests passing