How to map JSON from bank in Dapper using C # dictionary?

c# dapper dictionary json mysql

Question

I have a MySQL database and I have a JSON column that stores items as follows:

[{"key":"value"},{"key2","value2"},...}

How can I handle this and load into a C # dictionary? I'm getting error converting from string to dictionary

Example of model:

public class Person
{
  string name;
  Dictionary<string, string> itens;
}

Popular Answer

You have to create a Custom Handler. I've written detailed articles on that subject.

Samples are also available on GitHub:

https://github.com/yorek/dapper-samples

I've used SQL Server as RDBMS, but everything should apply as is to MySQL



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why