none
LINQ Query. RRS feed

  • Question

  • I want linq to OBJECT query for following for SHAREPOINT:

    Created   ---------> column name

    2011-01-25

    2011-02-12

    2011-02-18

    2011-03-27

    and so on.

    i want results like this(in LINQ)

    Month Count

    Jan  1

    Feb 2

    Mar  1

    Kindly Help.



    Monday, February 27, 2012 6:45 AM

Answers

  • Try the below. I haven't tried so please check the code and let me know if you face any problem.

    var grpTable = from grp in table1
         group grp by new { month = grp.Created.Month} into m
         select new { dtMonth = string.Format("{0}",m.Key.month), count = m.Count() };

    • Marked as answer by Ind_Alchemist Wednesday, February 29, 2012 5:57 AM
    Monday, February 27, 2012 10:14 AM