I created a class which represents an aggregated record from database query:
class list2d
{
private string ser;
private DateTime dat;
private int howmuch;
public list2d(string ser, DateTime dat, int howmuch)
{
this.ser = ser;
this.dat = dat;
this.howmuch = howmuch;
}
public string Ser { get; set; }
public DateTime Dat { get; set; }
public int HowMuch { get; set; }
}
So every object returns info about quantity (howmuch) one of distribution channels (ser) per day (dat) Then I created list<> of my objects and fill it with data from my database
List<list2d> listz = new List<list2d>();
foreach (DataRow row in dt.Rows)
{
listz.Add(new list2d(
row["SOURCE"].ToString(), (DateTime)row["DATE"], (int)row["HOWMUCH"]));
}
So right now I want to group these data by week (return_week(DATE) )and distribution channel and count it. As far as I searched stackoverflow it seems linq is correct "tool". Unfortunately I am not familiar with this feature but most of examples base on simply list of int or strings. In my case it is list of objects.