-
-
Notifications
You must be signed in to change notification settings - Fork 11
4.2. Working with array types
Vedran Bilopavlović edited this page Mar 26, 2021
·
4 revisions
Norm also supports mapping the array
types for all mapping extensions, for databases that support the array
types (PostgreSQL
for example).
Examples:
using System.Linq;
//...
var id = connection.Read<int[]>("select array_agg(id) from table").Single();
// id is int[]
var results = connection.Read<int[]>("select array_agg(id) from table").Single();
// `result` is IEnumerable<int[]>
var (ids, values) = connection.Read<int[], string[]>("select array_agg(id), array_agg(value) from table");
// `ids` is IEnumerable<int[]> and `values` is IEnumerable<string[]>
public class Test
{
public int[] Ids { get; set; }
public string[] Foos { get; set; }
}
//...
var results = connection.Read<Test>("select array_agg(id) as ids, array_agg(foo) as foos from table");
- 2.1. Execute(command, params) connection extension
- 2.2. Read(command, params) connection extensions
- 2.3. Multiple(command, params) connection extension
- 3.1. Working with basic type parameters
- 3.2. Working with class and record type parameters
- 3.3. Working with tuple type parameters
- 4.1. Working with parameters
- 5. Asynchronous programming
- 6. Utility extensions