using System.Collections.Generic;
public static void Main()
IList<employee> employees = new List<employee>() {
new employee() { employeeId = 1, employeeName = "John",month="1",salary="1000" } ,
new employee() { employeeId = 1, employeeName = "John",month="2",salary="2000" } ,
new employee() { employeeId = 1, employeeName = "John",month="3",salary="3000" } ,
new employee() { employeeId = 1, employeeName = "John",month="4",salary="4000" } ,
var Slarys = employees.Where(s => s.employeeId==1).ToList();
var result=( from s in Slarys.Where(r=>r.month==currentMonth.ToString())
group s by s into results
select new {name=results.Select(a=>a.employeeName).SingleOrDefault(),
NewMonth=results.Select(a=>a.month=currentMonth.ToString()).SingleOrDefault(),
OldMonth=results.Select(a=>a.month=(currentMonth-1).ToString()).SingleOrDefault(),
salaryNew=results.Where(l=>l.month==currentMonth.ToString()).Select(a=>a.salary).SingleOrDefault(),
salaryOld=results.Where(l=>l.month==(currentMonth-1).ToString()).Select(a=>a.salary).SingleOrDefault()
var json = JsonSerializer.Serialize(result);
public int employeeId { get; set; }
public string employeeName { get; set; }
public string month { get; set; }
public string salary { get; set; }