static void Main(string[] args) { IList orderList = new List() { new Order() { Id = 1, OrderDateTime = new DateTime(2019, 11, 12, 22, 45, 12, 004), CustomerName = "ABC", Status = "Completed",DoneBy="Cenk"} , new Order() { Id = 2, OrderDateTime = new DateTime(2019, 11, 12, 22, 45, 12, 004), CustomerName = "A", Status = "Ccancelled",DoneBy="Cenk" } , new Order() { Id = 3, OrderDateTime = new DateTime(2022, 07, 12, 22, 45, 12, 004), CustomerName = "dsds", Status = "Contiues",DoneBy="Cenk" } , new Order() { Id = 4, OrderDateTime = new DateTime(2022, 08, 12, 22, 45, 12, 004) , CustomerName = "dsds", Status = "Completed",DoneBy="Cenk"} , new Order() { Id = 5, OrderDateTime = new DateTime(2022, 09, 12, 22, 45, 12, 004) , CustomerName = "jdsj",Status = "Completed",DoneBy="Cenk" } }; // OrderDetail collection IList orderDetailList = new List() { new OrderDetail() { Id = 1, ProductCode = "12345", ProductName = "modem1",BuyQuantity=1,SellQuantity=10,CostRatio=2 , UnitCost=5,TotalBuyPrice=10,TotalSellPrice=15,Status = "Completed",ShippingNumber="Cenk", TrackingNumber="72827", Description="Test", OrderId=1, VendorId=2} , new OrderDetail() { Id = 2, ProductCode = "Erf7899", ProductName = "modem2",BuyQuantity=2,SellQuantity=10,CostRatio=2 , UnitCost=5,TotalBuyPrice=10,TotalSellPrice=15,Status = "Contiunes",ShippingNumber="Cenk", TrackingNumber="72827", Description="Test", OrderId=2, VendorId=1 } , new OrderDetail() { Id = 3, ProductCode = "0090owd", ProductName = "modem3",BuyQuantity=10,SellQuantity=15,CostRatio=2 , UnitCost=1,TotalBuyPrice=10,TotalSellPrice=15,Status = "Completed",ShippingNumber="Cenk", TrackingNumber="72827", Description="Test", OrderId=2, VendorId=2 } , new OrderDetail() { Id = 4, ProductCode = "fse929", ProductName = "modem4",BuyQuantity=11,SellQuantity=15,CostRatio=2 , UnitCost=5,TotalBuyPrice=10,TotalSellPrice=15,Status = "Cancelled",ShippingNumber="Cenk", TrackingNumber="72827", Description="Test", OrderId=2, VendorId=1} , new OrderDetail() { Id = 5, ProductCode = "1009ksks", ProductName = "modem5",BuyQuantity=19,SellQuantity=1,CostRatio=2 , UnitCost=1,TotalBuyPrice=10,TotalSellPrice=15,Status = "Completed",ShippingNumber="Cenk", TrackingNumber="72827", Description="Test", OrderId=3, VendorId=2 }, new OrderDetail() { Id = 6, ProductCode = "556dhdk", ProductName = "modem6",BuyQuantity=9,SellQuantity=13,CostRatio=2 , UnitCost=5,TotalBuyPrice=10,TotalSellPrice=15,Status = "Completed",ShippingNumber="Cenk", TrackingNumber="72827", Description="Test", OrderId=1, VendorId=2 } , new OrderDetail() { Id = 7, ProductCode = "99999", ProductName = "modem7",BuyQuantity=10,SellQuantity=14,CostRatio=2 , UnitCost=15,TotalBuyPrice=10,TotalSellPrice=15,Status = "Completed",ShippingNumber="Cenk", TrackingNumber="72827", Description="Test", OrderId=3, VendorId=1 }, new OrderDetail() { Id = 8, ProductCode = "00000", ProductName = "modem8",BuyQuantity=1,SellQuantity=15,CostRatio=2 , UnitCost=1,TotalBuyPrice=10,TotalSellPrice=15,Status = "Completed",ShippingNumber="Cenk", TrackingNumber="72827", Description="Test", OrderId=4, VendorId=1 } }; // vendor collection IList vendorList = new List() { new Vendor() { Id = 1, Name = "Vendor1", Address = "ABC Address", Email = "Email", PhoneNumber="1234353", MainResponsibleName="test", AssistantResponsibleName="test1"} , new Vendor() { Id = 2, Name = "Vendor1", Address = "ABC Address", Email = "Email", PhoneNumber="1234353", MainResponsibleName="test", AssistantResponsibleName="test1" } }; // LINQ Query Syntax to find out teenager students var result1 = from order in orderList from orderdetail in orderDetailList where order.Id == orderdetail.OrderId && order.OrderDateTime > DateTime.Now.AddMonths(-4) select new { order.OrderDateTime, orderdetail.TotalSellPrice }; var result2 = from order in result1 group order by new { order.OrderDateTime.Year, order.OrderDateTime.Month } into grup select new { year = grup.Key.Year, month = grup.Key.Month, total = grup.Sum(m => m.TotalSellPrice) }; }