Solved

into dateGroup  LINQ statement ???

Posted on 2014-02-21
3
304 Views
Last Modified: 2016-02-10
I was wondering if I could get an explanation bellow....  not sure what it mean into dateGroup or what this querry mean bellow....

 var data = from student in db.Students
               group student by student.EnrollmentDate into dateGroup
               select new EnrollmentDateGroup()
               {
                   EnrollmentDate = dateGroup.Key,
                   StudentCount = dateGroup.Count()
               };
    return View(data);
0
Comment
Question by:yguyon28
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39877853
Hi yguyon28;

Please see the comments in the code.

// The db is most likely a object of some DataContext such as a database
// This first line will Iterate through the Students table, Each iteration 
// will put a single student record into student.
var data = from student in db.Students
           // This next line will group the student records from the Students table 
           // into groups which have the same EnrollmentDate, so all Students within 
           // a single group will have the same in EnrollmentDate and dateGroup is 
           // an object that will contain all the groups.
           group student by student.EnrollmentDate into dateGroup
           // The EnrollmentDateGroup is a class with at miniumn two public properties, 
           // EnrollmentDate and StudentCount. One of these classes is created for each 
           // group in dateGroup. 
           select new EnrollmentDateGroup()
           {
               // The value of Key is the identification of each group which is 
               // EnrollmentDate
               EnrollmentDate = dateGroup.Key,
               // the value in StudentCount is the total number of students in a 
               // particular group.
               StudentCount = dateGroup.Count()
           };
           
// This seems to be an ASP MVC application so the results of the above query
// is being returned to the view for the function.           
return View(data);

Open in new window

0
 

Author Closing Comment

by:yguyon28
ID: 39878049
Thank u for the answer and ur time.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39878054
Not a problem yguyon28, glad to help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question