Details
Currently, Gridify's GenerateMappings automatically creates indexer mappings (e.g. prop[0]) only for collections of complex types, not for collections of primitives (such as List, int[], etc.). This leads to the following issue:
- When a model contains a property like List DogIds, only the default accessor mapping is generated ("dogIds"), which supports collection membership queries (e.g., dogIds=2).
- If a user adds an indexer mapping manually for that property (e.g., mapper.AddMap("dogIds", (p, idx) => p.DogIds[idx])), it replaces the default mapping, so you can't have both dogIds=2 and dogIds[0]=2 queries working at the same time under the original key.
Feature Suggestion:
- Enhance GenerateMappings so that, for collections of primitives, it automatically creates both the default mapping (for collection membership) and an indexer mapping (for indexed access) under separate keys (such as "dogIds" and "dogIds[index]").
- This would allow both membership and indexer queries to work out-of-the-box for primitive collections, just like for complex collections.
Benefits:
- Consistency with how mappings work for complex-type collections
- Less manual configuration for users
- Enables both membership and indexer-based filtering without breaking default behavior
Possible Implementation:
- Auto-generate two mappings for any collection of primitives: one for the collection itself, and one for the indexer (e.g., "dogIds[index]").
- Document the behavior and naming convention in the official docs.
This enhancement would simplify usage and remove manual mapping workarounds for common scenarios involving collections of primitives.
Details
Currently, Gridify's GenerateMappings automatically creates indexer mappings (e.g. prop[0]) only for collections of complex types, not for collections of primitives (such as List, int[], etc.). This leads to the following issue:
Feature Suggestion:
Benefits:
Possible Implementation:
This enhancement would simplify usage and remove manual mapping workarounds for common scenarios involving collections of primitives.