Group a customer list by enum and maximum number of items per enum

Dear Experts:
My need is to group a list of customers (List<Customer>) where Customer contains this enum
public enum CustomerType
{
  type1,
  type2,
  type3,
  type4,
  type5
}

Open in new window

grouped by type and number of items per type (in this case 50); for example if customers contain:
70  type1,
120  type2 and
51  type5
your answer should return a list of Dictionary objects like:
Object 1:
50  type1,
50  type2 and
50  type5
Object 2:
20  type1,
50  type2 and
1  type5
Object 3:
50  type2
Note: Basically the Dictionary object works like a page that contains a maximum of 50 items of any type.
LINQ/non LINQ answers should be OK, but I prefer LINQ.
LVL 37
Miguel OzSoftware EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Najam UddinCommented:
custs.GroupBy(n => n.ctype, (key, values) => new { ctype = key, Count = values.Count() });

custs is customer collection
ctype is property for customertype
Miguel OzSoftware EngineerAuthor Commented:
Nope, this is not correct it is only counting the number of items and the requirement is to page these objects .
I have already had an answer from SO: ( I can not add the link due to EE policies)
var max=cust.GroupBy(c=>c.CustomerType).Select(c=>c.Count()).Max();
var dict=Enumerable
  .Range(0,(max-1)/pageSize+1)
  .Select(page=>
    cust.GroupBy(c=>c.CustomerType)
      .Select(c=>
        c.Skip(page*pageSize)
          .Take(pageSize))
    .SelectMany(c=>c));

Open in new window

I will leave this open just in case, you would like to contribute/improve the above query.
Thanks,

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Miguel OzSoftware EngineerAuthor Commented:
NO comments after I posted
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.