DapperAOT
DapperAOT copied to clipboard
Don't report DAP037 on (other) array types
#125 added result type support for byte[] & sbyte[] to handle BLOBs.
Some databases support columns to be arrays of different types. E.g. PostgreSQL or Clickhouse.
Npgsql maps array types to Array (of element type).
Dapper vanilla supports arrays (of other types) as a result type, while DapperAOT reports DAP037.
For example (PostgreSQL):
create table arrays_table
(
id int4 not null unique,
strings text[],
ints int4[]
);
insert into arrays_table (id, strings, ints) values
(1, array['a', 'b', 'c'], array[1, 2, 3]),
(2, array['d', 'e', 'f'], array[4, 5, 6]),
(3, array['g', 'h', 'i'], array[7, 8, 9]);
With Dapper vanilla an array column can be selected as
IEnumerable<string[]> result = await conn.Query<string[]>("select strings from arrays_table")
or string[]? strings = conn.QuerySingleOrDefault<string[]>("select strings from arrays_table where id = 1"),
but with DapperAOT these fail to compile.