Nagarajaswamy

Nagarajaswamy

  • NA
  • 86
  • 13.1k

Access JSON data from Database Table to WPF datagrid

Mar 27 2017 10:43 AM
Hi everyone,

I am writing an application, For that I am using WPF and SQL.

Below is my requirement, Please look into the below requirement and help me to solve my problem.

Requirement is given below:

I have a WPF window with one DataGrid and one Button.

I am reading data from database and displaying that data into WPF Datagrid.

Table structure is as below:
(All columns are of nvarchar type)
Col1 Col2 Col3 Col4
1       2     1      [{"Name":"A1","Vol":10},{"Name":"A2","Vol":1},{"Name":"A3","Vol":11}]
1       2     2      [{"Name":"A1","Vol":20},{"Name":"A2","Vol":2},{"Name":"A3","Vol":22}]
1       2     3      [{"Name":"A1","Vol":30},{"Name":"A2","Vol":3},{"Name":"A3","Vol":33}]
1       3     1      [{"Name":"A1","Vol":40},{"Name":"A2","Vol":4},{"Name":"A3","Vol":44}]
1       3     2      [{"Name":"A1","Vol":50},{"Name":"A2","Vol":5},{"Name":"A3","Vol":55}]

All columns are of type nvarchar. Since col4 has huge data, Im storing data in JSON format.
(because each set has to be represented as a column in the output window)


Output that I am expecting is,

Col1 Col2 Col3 A1  A2  A3
1       2       1   10  1   11
1       2       2   20  2   22
1       2       3   30  3   33
1       3       1   40  4   44
1       3       2   50  5   55


Table can contain data upto 50,000 rows and Col4 can contain data upto 300 sets
(here I have mentioned only 3 set of data for col4)


In order to perform this operation for 50,000 data and 300 set of data in col4, It has to take less than a second of time.
This is what the requirement.

I am able to do it in 10 seconds, but couldn't achieve in less than one or two seconds. Please help me.


Attachment: JsonAndWPF.zip

Answers (3)