Skip to content

feat: support explicit field binding in QueryModelTypeModule#24

Merged
Theauxm merged 2 commits into
mainfrom
feat/explicit-field-binding
Mar 25, 2026
Merged

feat: support explicit field binding in QueryModelTypeModule#24
Theauxm merged 2 commits into
mainfrom
feat/explicit-field-binding

Conversation

@Theauxm
Copy link
Copy Markdown
Member

@Theauxm Theauxm commented Mar 25, 2026

Summary

  • QueryModelTypeModule now checks TraxQueryModelAttribute.BindFields when creating ObjectType<T>
  • When Explicit, calls BindFieldsExplicitly() and auto-binds only [Column]-attributed properties
  • [NotMapped] properties, methods, and non-column public members are excluded from the schema
  • FK fields via ObjectTypeExtension (custom TypeModules) still work since extensions are separate

Context

Depends on TraxSharp/Trax.Effect#43 for the FieldBindingBehavior enum and BindFields attribute property.

Test plan

  • dotnet build passes with zero warnings
  • All 234 tests pass including 5 new explicit binding tests
  • Attribute default preserved (Implicit)
  • Builder scanning preserves BindFields through QueryModelRegistration
  • CreateTypesAsync produces correct types for both binding modes

When TraxQueryModelAttribute.BindFields is Explicit, the generated
ObjectType calls BindFieldsExplicitly() and only binds properties
with [Column] attributes. This prevents [NotMapped] aliases, DataLoader
methods, and infrastructure methods from leaking into the schema.
@Theauxm Theauxm merged commit 150a012 into main Mar 25, 2026
1 check passed
@Theauxm Theauxm deleted the feat/explicit-field-binding branch March 25, 2026 20:30
@traxsharp
Copy link
Copy Markdown

traxsharp Bot commented Mar 25, 2026

This PR is included in version 1.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant