You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Single-dimensional PostgreSQL arrays are well-supported, but not multi-dimensional ones. This issue is meant to see how many people actually want this - please upvote if you'd benefit from it.
Things that need to be implemented:
Literal value generation
ValueComparer (comparison and snapshotting)
PostgresArrayIndexExpression needs to have multiple indexes, just like .NET ArrayIndexExpression
@roji The documentation here: http://www.npgsql.org/efcore/mapping-and-translation.html says However, operations such as indexing the array, searching for elements in it, etc. aren't yet translated to SQL and will be evaluated client-side. This will probably be fixed in 1.2.
Since the latest version is over 2.0, i wanted to check - is something like
context.MyEntities.FirstOrDefault(x => x.ArrayProperty.Any(i => i == 42)) expected to be evaluated client side or actually sent to the backend?
(i noticed that Contains() is listed as supported on the same page)
Will fix the docs, thanks. Yes, array operation translation was added to 2.0, which means server-evaluation (see #120). The translation list on the docs page is correct, I'll remove the old sentence you spotted. If you run into any issues or client evaluation occurs, please open a new issue.
Note, however, multidimensional arrays (this issue) aren't supported at all as well as single-dimensional ones.
@roji I want to write and read a model with a two-dimensional array property. It seems to save correctly, but it gives an index-out-of-range exception when I'm trying to read it
@Rincho-M saving and loading is generally supposed to work: see the following minimal code sample which works for me with 7.0; if you're seeing something different, please open a new issue with a minimal repro. Anything beyond that may not work though.
@roji so I did some testing and it appears that it doesnt work only with char arrays. And not only with multidimensional arrays, but with one-dimentional ones too. I didnt find opened issue with this error so I will try to open one on this weekend
This appears to work with int[,] and double[,], at least with Postgres, but not enums, e.g. MyEnum[,].
Given that enums are just integers, is there an easy way to support this?
Is there a workaround outside of a custom json serialization? IE:
way.Property(w =>w.Nodes).HasColumnName("nodes").HasColumnType("jsonb").HasConversion(
v =>JsonSerializer.Serialize(v,(JsonSerializerOptions?)null),
v =>JsonSerializer.Deserialize<long[][]>(v,(JsonSerializerOptions?)null)!);
@Pieeer1 basic multidim array support is there - if all you want to do is serialize/deserialize (value converters aren't supported, possibly some other edge cases). So if all you want to do is serialize/deserialize (which is what your JSON value converter does), then you shouldn't need anything else.
Note that PG has a proper array type, rather than serializing arrays to JSON.
I was getting some issues with a bigint[][] with the data type set, I can retry without the custom column type and see what I get with the migration.
Well it would make sense why it wasn't liking it, apparently osm2pgsql stores the data in a bigint[][] but in reality it is actually just a singular dimensional big int array.
I was working with integer[,] for a while now. After updating to the latest ef core version I am getting „Unable to cast object of type 'System.Int32[]' to type 'System.Int32[,]'“ when querying empty arrays.
Were there some breaking changes?
Activity
Added value comparer for arrays
Added value comparer for arrays
Added value comparer for arrays
Added value comparer for arrays
Added value comparer for arrays
Added value comparer for arrays
Added value comparer for arrays
Added value comparer for arrays
alexzaytsev-newsroomly commentedon May 6, 2018
@roji The documentation here: http://www.npgsql.org/efcore/mapping-and-translation.html says
However, operations such as indexing the array, searching for elements in it, etc. aren't yet translated to SQL and will be evaluated client-side. This will probably be fixed in 1.2.Since the latest version is over
2.0, i wanted to check - is something likecontext.MyEntities.FirstOrDefault(x => x.ArrayProperty.Any(i => i == 42))expected to be evaluated client side or actually sent to the backend?(i noticed that
Contains()is listed as supported on the same page)roji commentedon May 6, 2018
Will fix the docs, thanks. Yes, array operation translation was added to 2.0, which means server-evaluation (see #120). The translation list on the docs page is correct, I'll remove the old sentence you spotted. If you run into any issues or client evaluation occurs, please open a new issue.
Note, however, multidimensional arrays (this issue) aren't supported at all as well as single-dimensional ones.
Added value comparer for arrays
2 remaining items
Rincho-M commentedon Sep 5, 2023
Are there any plans to implement this feature, or is it the same as it was five years ago?
roji commentedon Sep 5, 2023
@Rincho-M so far this hasn't received enough user feedback to warrant spending the time on it. What exact capability are you missing here?
Rincho-M commentedon Sep 6, 2023
@roji I want to write and read a model with a two-dimensional array property. It seems to save correctly, but it gives an index-out-of-range exception when I'm trying to read it
roji commentedon Sep 7, 2023
@Rincho-M saving and loading is generally supposed to work: see the following minimal code sample which works for me with 7.0; if you're seeing something different, please open a new issue with a minimal repro. Anything beyond that may not work though.
Code sample
Rincho-M commentedon Sep 7, 2023
@roji so I did some testing and it appears that it doesnt work only with char arrays. And not only with multidimensional arrays, but with one-dimentional ones too. I didnt find opened issue with this error so I will try to open one on this weekend
MattParkerDev commentedon Sep 23, 2024
This appears to work with int[,] and double[,], at least with Postgres, but not enums, e.g. MyEnum[,].
Given that enums are just integers, is there an easy way to support this?
roji commentedon Sep 23, 2024
Enums need to be value-converted internally, and the value converter that takes care of arrays doesn't support multidimensional ones yet.
Pieeer1 commentedon Oct 30, 2025
Is there a workaround outside of a custom json serialization? IE:
roji commentedon Oct 31, 2025
@Pieeer1 basic multidim array support is there - if all you want to do is serialize/deserialize (value converters aren't supported, possibly some other edge cases). So if all you want to do is serialize/deserialize (which is what your JSON value converter does), then you shouldn't need anything else.
Note that PG has a proper array type, rather than serializing arrays to JSON.
Pieeer1 commentedon Oct 31, 2025
I was getting some issues with a bigint[][] with the data type set, I can retry without the custom column type and see what I get with the migration.
Pieeer1 commentedon Oct 31, 2025
Well it would make sense why it wasn't liking it, apparently osm2pgsql stores the data in a bigint[][] but in reality it is actually just a singular dimensional big int array.
DG4ever commentedon Jun 15, 2026
I was working with integer[,] for a while now. After updating to the latest ef core version I am getting „Unable to cast object of type 'System.Int32[]' to type 'System.Int32[,]'“ when querying empty arrays.
Were there some breaking changes?
roji commentedon Jun 17, 2026
Please open a new issue for that, with a minimal repro that clearly shows the regression