$50
Assignment 7 LINQ to Objects Query
)
1. As an example, you are given an Excel file Courses.csv in the “comma separated values” format, which is copied from the ASU course list. The list is modified for the assignment. Do not use the list for scheduling you class. You must add at least 10 classes into the list so that the data are sufficient to show all the features that are required. You will write a program to create an in-memory array from the data source and then query the data source using LINQ to Objects classes. Use comments to indicate what part of code answers which question. You can use a console application or other .Net application template to implement this assignment. You can put the Courses.csv into the App_Data folder in your application.
1.1 Define a Course class consisting of at least the following members: CourseId, Subject, CourseCode, Title, Location, and Instructor. Write a program to read the Courses.csv file and create an in-memory
array of objects of the Course class. [10]
Hint: Start from the program given in Question 5 in Practice Exercises part.
1.2 Create the following LINQ queries to extract data from your in-memory data source.
a. Retrieve the list of IEE courses with a course number / code of 300 or higher. Deliver the result set in the type of IEnumerable<T, where each entity contains course title and course instructor. The result set must be sorted by instructor and in ascending order. Print the results.
[5]
b. Retrieve and deliver the courses in groups and subgroups (in two levels): Use the course subject, (e.g., CPI, CSE, and IEE), as the first level key, and use the course code (e.g., 240, 310, and 494) as the second level key. Print the groups that have at least two courses in the second level group. Hint: Read the example in text 10.3.3 and lecture slides 4-2. [10]
1.3 Create a new file called Instructors.csv. The schema of the file is: instructor name, office number, and email address. Choose at least 30 instructors from Courses.csv list and add them into your Instructors file. You can find the information from CIDSE faculty directory at : https://cidse.engineering.asu.edu/facultyandresearch/directory/faculty/
You can make up an office number and the email address if you cannot find the information from the site. Each email address must be unique. You can create the file manually using Excel. [5]
1.4 Define the Instructor class consisting of the following members: InstructorName, OfficeNumber, and EmailAddress. Write a program to read the Instructors.csv file and create an in-memory list of the
objects of the Instructor class. [10]
1.5 Use the Courses array and Instructors list as two data sources. Write a query to find the course instructor’s email address for each course. Deliver the result set in the type var, where each entity contains Subject CourseCode (e.g., CSE 310) and the course’s instructor email address. The result set must be sorted by CourseCode in ascending order. Print the results for all 200 level courses. [10]
Assignment 8 LINQ Application
)
2. For the same Excel file Courses.csv file, in this part of the assignment, you will create an XML document from the data source and query the XML data source using LINQ to XML classes. Use comments to indicate what part of code answers which question. You can use a console application or other .Net application template to implement this assignment. You can put the Courses.csv into the
App_Data folder in your application. [50 points]
2.1 Define the Course class consisting of at least the following members: CourseId, Subject, CourseCode, Location, and Instructor. Write a program to read the Courses.csv file and create an in-memory XML
file of the objects of the Course class. [10]
2.2 Save the XML document into the App_Data folder in your application. [10]
2.3 Create the following LINQ queries to extract data from your in-memory XML source.
a. Retrieve the list of CPI courses with a course number of 200 or higher. Deliver the result set in the type of IEnumerable<XElement, where each entity contains course title and course instructor. The result set must be sorted by instructor in ascending order. Print the results. [5]
b. Retrieve and deliver the courses in groups in two levels: Use the course subject, (e.g., CPI, CSE, and IEE), as the first level key, and use the course code (e.g., 240, 310, and 494) as the second level key. Print the groups that have at least two courses in the second level group. [10]
2.4 Use the Course XML document and Instructors list (created Assignment 7) as data sources. Write a query to find each course and the course instructor’s email address. Deliver the result set in the type IEnumerable<XElement, where each entity contains Subject and CourseCode (e.g., CSE 310) and course instructor’s email address. The result set must be sorted by CourseCode in ascending order.
Print the results for all 200 level courses.