In my opinion, using Fluent Syntax usually makes it a bit easier to understand what is going wrong here.

As soon as you group your data you are no longer working on the individual objects, but on a 'group', which is the key and an enumerable of objects.

Getting the sum per employee should then be grouping by the full employee id and then parsing the MNTH1 fields of your objects and summing them.

dataGridView1.DataSource = movie2
    .GroupBy(p => p.EMPLID)  // create a group of data per employee
    .Select(g => new
        EMPLID = g.Key,  // the employee id is the group key
        Sum = g.Sum(data => decimal.Parse(data.MNTH1))  // parse and sum

Edit: you are right, you need the ToArray to evaluate the query. I just verified on my computer and it works.


Try following :

    class Program
        static void Main(string[] args)
            IEnumerable<AssgnData> movie2 = null;

            dataGridView1.DataSource = movie2.GroupBy(x => new {id = x.EMPLID, month = x.MNTH1})
                .Select(x => new {
                    EMPLYID =,
                    MONTH = x.Key.month,
                    SUM = x.Sum(y => y.value)
    public class AssgnData
        public string EMPLID { get; set; }
        public string MNTH1 { get; set; }
        public int value { get;set;}

Related Articles