Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<Prices> List1 = new List<Prices>();
- List1.Add(new Prices { Year = 2018, Price = 1.5m });
- List1.Add(new Prices { Year = 2017, Price = 1.2m });
- List1.Add(new Prices { Year = 2016, Price = 3.5m });
- //The linq query i'm trying to build
- var data1 = List1.Select(c=> new
- {
- labels = new List<Int64> {f=> f.Year },
- series = new List<decimal> {
- new List<decimal> { Convert.ToDecimal(c.Price) }
- }
- });
- // it's what i want to build
- var data2 = new {
- labels = new List<Int64> { 2018, 2017, 2016 },
- series = new List<decimal[]> {
- new decimal[] { 1.5m, 1.2m, 3.5m }
- }
- };
- var Json = JsonConvert.SerializeObject(data2);
- //Json => {"labels":[2018,2017,2016],"series":[[1.5,1.2,3.5]]}
Add Comment
Please, Sign In to add comment