using System.Collections.Generic;
public static void Main()
var list = new List<RoomDetails>
new RoomDetails(1,1,200,"SingleBed"),
new RoomDetails(2,1,250,"Double Bed"),
new RoomDetails(2,2,400,"Double Bed with Extra View"),
new RoomDetails(2,4,530,"Tripple Bed"),
new RoomDetails(3,1,530,"Tripple Bed"),
new RoomDetails(3,2,600,"Triple Large Bed"),
var total = list.GroupBy(x=>x.RoomIndexID)
.Aggregate(1, (s,d)=>s*d);
var counts = list.GroupBy(x => x.RoomIndexID)
.ToDictionary(x => x.Key, x => x.Count());
var nums = list.GroupBy(x => x.RoomIndexID)
.Select(x => x.Select((p, i) => new {i, p}))
var result = Enumerable.Range(0, total)
var c = counts[y.p.RoomIndexID];
var p = counts.Where(z => z.Key > y.p.RoomIndexID).Aggregate(1, (s,d)=>s*d.Value);
Console.WriteLine("==================================");
public RoomDetails(int roomIndexID, int roomcategoryID, decimal roomPrice, string roomCategory)
this.RoomIndexID = roomIndexID;
this.roomcategoryID = roomcategoryID;
this.roomPrice = roomPrice;
this.roomCategory = roomCategory;
public int RoomIndexID { get; set; }
public int roomcategoryID { get; set; }
public decimal roomPrice { get; set; }
public string roomCategory { get; set; }
public override string ToString()
return string.Format("{0}, {1}, {2}, {3}", RoomIndexID, roomcategoryID, roomPrice, roomCategory);