Mapping arrays for properties (IReadOnlyCollection) with backing fields
See original GitHub issueMapping arrays feature is really cool https://www.npgsql.org/efcore/mapping/array.html
However when I work with DDD I would like to expose collections as readonly using IEnumerable
or IReadOnlyCollection
public class Entity
{
public IReadOnlyCollection<Guid> Attributes => attributes ;
private Guid[] attributes = Array.Empty<Guid>();
}
and then, when I use LINQ on entity with backing field
.Where(c => c.Attributes.Contains(id))
it will generate in memory query instead of SQL query
WHERE "guid" = ANY("c"."Attributes")
Is it possible to support LINQ with sql properly for IReadOnlyCollection
with backing fields?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Mapping arrays for properties (IReadOnlyCollection) with ...
Is it possible to support LINQ with sql properly for IReadOnlyCollection with backing fields?
Read more >c# - How to setup readonly collection property with backing ...
I ckeck this and it worked: private readonly List<RelatedEntity> _relatedEntitys; public IReadOnlyCollection<RelatedEntity> RelatedEntitys ...
Read more >Untitled
... c Mapping arrays for properties (IReadOnlyCollection) with backing … ... property typed as IReadOnlyCollection, which is backed by a private field ......
Read more >What's New in EF Core 7.0
Notice that this convention allows fields to be mapped (in addition to properties) so long as they are marked with [Persist] . This...
Read more >Collection Types in Data Contracts - WCF
A collection is a list of items of a certain type. In the .NET Framework, such lists can be represented using arrays or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, that’s what I meant - check out the docs on mapping fields without properties. The point is that EF Core doesn’t need to map - or even know - the property in question, it’s just a user-facing wrapper over the private field, which provides casting.
Checked that the new ordered dictionary class implements
IList<T>
. So other ordered collections should implement it as well, and there is no reason to support collection interfaces. ButArrayHandler
lacks support of read only lists.