Code Monkey home page Code Monkey logo

Comments (7)

roji avatar roji commented on August 17, 2024

We should indeed provide a bit of documentation.

At the ADO level, Npgsql supports all the array capabilities of PostgreSQL itself, so in general what you find in the PostgreSQL docs is supported. Note that PostgreSQL does not support arrays of arrays, but does support multi-dimensional arrays (you can see some examples in the docs). You can use either .NET arrays or generic Lists to map to PostgreSQL arrays.

Note, however, that the EF Core provider's multi-dimensional arrays support is very limited - basically stick to one-dimensional arrays.

from doc.

natalie-o-perret avatar natalie-o-perret commented on August 17, 2024

Note that PostgreSQL does not support arrays of arrays, but does support multi-dimensional arrays (you can see some examples in the docs). You can use either .NET arrays or generic Lists to map to PostgreSQL arrays.

@roji Hey thanks for your answer! Much appreciated!

One thing though, when you're saying:

Note that PostgreSQL does not support arrays of arrays, but does support multi-dimensional arrays (you can see some examples in the docs)

How does it work in npgsql to benefit from the multidimensional array support then?

NpgsqlDbType.Array | NpgsqlDbType.Array | NpgsqlDbType.SmallInt

from doc.

roji avatar roji commented on August 17, 2024

Nope, just NpgsqlDbType.Array | NpgsqlDbType.SmallInt. That corresponds to an array of any dimensions in PostgreSQL.

from doc.

natalie-o-perret avatar natalie-o-perret commented on August 17, 2024

Nope, just NpgsqlDbType.Array | NpgsqlDbType.SmallInt. That corresponds to an array of any dimensions in PostgreSQL.

@roji Alright, that's a little bit counterintuitive... just to make this super-duper clear, with NpgsqlDbType.Array | NpgsqlDbType.SmallInt, you can pass resp. int[], int [,], int[,,], int[,,,] and even bigger dimensions?

from doc.

roji avatar roji commented on August 17, 2024

Yes. I know it may seem a bit odd, but the way PostgreSQL handles type arrays, all arrays of a given element type - regardless of dimension - are of a single type; this is why a single NpgsqlDbType value maps to them all.

from doc.

roji avatar roji commented on August 17, 2024

BTW regardless of PostgreSQL, NpgsqlDbType.Array | NpgsqlDbType.Array | NpgsqlDbType.SmallInt doesn't really make any sense in C# - ORing something will itself doesn't produce any useful effect.

from doc.

natalie-o-perret avatar natalie-o-perret commented on August 17, 2024

@roji alrite alrite, thanks! It makes sense now.

from doc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.