c# - Saving a Dictionary(Of String, Int16()) into a PostgreSQL cell -
i have dictionary(of string, int16()).
dictionary represents analog values measurement. want store dictionary 1 cell of postgresql database. using npgsql.
i searching long time, have no idea how that.
my thought serialize dictionary , save array, not sure if correct way.
is there out there, can me in matter?
thanks answers
have @ create type
create type stringintpairtype (k string,v int);
update: here full example of how accomplish pg sql
define element type of dictionary
create type stringintpairtype (k text,v int);
create sample table. note collection column marked '[]' @ end
create table collectionstables ( id serial unique, collection stringintpairtype[], description text, ts timestamp not null default now() )
inserts single record 2 dictionary elements
insert collectionstables(collection,description) values ( array [ ('test1',1)::stringintpairtype, ('test2',2)::stringintpairtype ], 'description1' );
inserts single record 2 dictionary elements
insert collectionstables(collection,description) values ( array [ ('testa',30)::stringintpairtype, ('testb',40)::stringintpairtype ], 'description2' );
note regular table other table
select * collectionstables
here more advanced select.
select collection[1].k,description collectionstables
first column: key of first dictionary value
second column: description column
Comments
Post a Comment