Could I please get some help with querying from a JSON file? Populating a datagrid view works just fine but what I am trying to do now is filter the data using LINQ which I'm really struggling with. This works just fine, populating the datagridview with all of my jsonfile data
//dataGridView1.DataSource = (from p in movie2 // select p).ToArray(); Below is what I have been playing around with. When I group by employee ID into g, I can not longer use my p references to fields.
using (StreamReader file = File.OpenText(@"C:\temp\GRMReportingJSONfiles\Assigned_FTE\" + myFile)) { JsonSerializer serializer = new JsonSerializer(); IEnumerable<AssgnData> movie2 = (IEnumerable<AssgnData>)serializer.Deserialize(file, typeof(IEnumerable<AssgnData>)); dataGridView1.DataSource = (from p in movie2 group p by p.EMPLID[0] into g select new { EMPLID = p.EMPLID, (decimal?)decimal.Parse(p.MNTH1) ?? 0).Sum(), }; ); //dataGridView1.DataSource = (from p in movie2 // select Int32.Parse(p.MNTH1).Sum(); dataGridView1.DataSource = (from p in movie2 group p by p.EMPLID[0] into g select (decimal?)decimal.Parse(p.MNTH1) ?? 0).Sum(); //dataGridView1.DataSource = (from p in movie2 // select p).ToArray(); //where p.Resource_BU == "7000776" //chart1.DataBindCrossTable(movie2, "MNTH1", "1", "PROJECT_ID", "Label = FTE"); //chart1.Refresh(); } Here is part of the array layout, removed other fields for now as I was just trying to focus on these two, dataset has 100k rows and 50 columns
public class AssgnData { public string EMPLID { get; set; } public string MNTH1 { get; set; } }