Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

into dateGroup  LINQ statement ???

Posted on 2014-02-21
3
Medium Priority
?
308 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
  • 2
3 Comments
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 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 64

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

926 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