How in Dapper can I map one column to a jSON?

c# dapper

Question

I have a table where I store a dictionary as json in one column. If feasible, I'd want to be able to hide the json de/serialization while saving or loading material to/from the database. Is there a way to do this with Dapper without requiring a separate Foo property that holds the JSON representation?

// where someData is the dictionary column
void Save(IDbConnection conn, Foo foo){
    conn.Execute("INSERT INTO foos (name, <othercols...>, someData) VALUES (@Name, <othercols...>, @SomeData, foo);
}

Although there are additional columns, manually mapping out Foo into a new dynamic object would be laborious. Is there any option?

1
2
5/2/2017 1:18:28 PM

Popular Answer

ZZZ_tmp
4
10/23/2017 10:16:52 AM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow