I have 2 tables:
CREATE TABLE "book"
(
"id" serial PRIMARY KEY,
"ean_number" TEXT NULL,
"title" TEXT NULL
);
CREATE TABLE "e_book"
(
"id" serial PRIMARY KEY,
"ean" TEXT NULL,
"title" TEXT NULL,
"format" VARCHAR(255) NOT NULL,
"physical_book_ean" TEXT NULL
);
There is a one to many or none relationship from book to e_book.
I want to run a query like this in my code:
var q = "select b.*, array_agg(e) ebooks from book b " +
"left join e_book e on e.physical_book_ean = b.ean_number " +
"group by b.id";
using (var cmd = new NpgsqlCommand(q, conn))
using (var reader = cmd.ExecuteReader())
while (reader.Read())
{
//read data
}
The array_agg column ebook comes up as content type <unknown>
How do I define the content type so I can read it?