0

I have a C# dictionary object I would like to pass to an SQL stored procedure and compare its contents to a field containing JSON string.

Dictionary<String,Object> d = new Dictionary<String,Object>
d.Add("A",True);
d.Add("B",False);

Let's presume that the table content is as follows. Based on the above dictionary would mean that the stored procedure returns record #2.

ID        JSON
----------------------------------------
1         { "A": false, "B": false }
2         { "A": true, "B": false }

I am aware of something called TVP but have no idea how to implement this in SQL or how to parse JSON. How would I achieve this?

leighhydes
  • 77
  • 1
  • 2
  • 8
  • 1
    See following link. Each function of the 4 functions on link has details and examples : https://learn.microsoft.com/en-us/sql/t-sql/functions/json-functions-transact-sql?view=sql-server-ver15 – jdweng Jul 10 '20 at 13:26
  • 2
    have u considered serializing Dictionary into a string before passing into SP? thus you'll have a simple strings comparison – Kiryl Jul 10 '20 at 15:24

0 Answers0