using System.Collections.Generic;
public static void Main()
var products = new List<Product>()
{new Product() {ProductID = 1, ShopID = 1, Amount = 1000, Price = 220, AddedDate = DateTime.Parse("2020-07-01")},
new Product() {ProductID = 1, ShopID = 1, Amount = 1000, Price = 230, AddedDate = DateTime.Parse("2020-07-30")},
new Product() {ProductID = 1, ShopID = 1, Amount = 100, Price = 21, AddedDate = DateTime.Parse("2020-07-10")},
new Product() {ProductID = 1, ShopID = 1, Amount = 100, Price = 22, AddedDate = DateTime.Parse("2020-07-31")},
new Product() {ProductID = 1, ShopID = 2, Amount = 100, Price = 23, AddedDate = DateTime.Parse("2020-07-10")},
new Product() {ProductID = 1, ShopID = 2, Amount = 100, Price = 20, AddedDate = DateTime.Parse("2020-07-12")},
decimal lowestPrice = (from s1 in products
where (from s2 in products
group s2 by new { s2.ShopID, s2.Amount } into g
select (g.Max(s2 => s2.AddedDate))
select (s1.Price / s1.Amount))
decimal highestPrice = (from s1 in products
where (from s2 in products
group s2 by new { s2.ShopID, s2.Amount } into g
select (g.Max(s2 => s2.AddedDate))
select (s1.Price / s1.Amount))
Console.WriteLine("Lowest price: " + lowestPrice);
Console.WriteLine("Highest price: " + highestPrice);
public DateTime AddedDate