logo

Understanding LINQ with CSV and XML

   

Added on  2023-04-19

2 Pages887 Words255 Views
LINQ abbreviation stands for Language Integrated Query. This query language is designed by Microsoft
and it can be easily integrated with programming language such as C# and VB. In past the developer has
to learn one programming language and one database or XML in order to access data but this LINQ has
simplified their lives and this can be integrated and provide easy access on data and provides in memory
object database feature and can create XML document in the memory itself. It is considered as common
application to connect with SQL and XML. LINQ has simplified the life of developer and they can write
queries within their program and can also interact with those data with the classes. LINQ helps to create
in memory data objects of class for the database and by using those in memory structure, developer can
query on the in memory objects like they are querying on SQL database. Queries in LINQ are somewhat
similar to the syntax of the SQL.
In assignment 7, CSV file is provided and CSV file is loaded in the class object and then queries are
created on it. There are two types of query are created one is the simple select query with filters and
another is the SQL join query in which two csv files are read into memory and then join is applied on it
and data is fetched.
In the first part of the question, the class Course is created with the attributes as CourseId, Subject,
Course Code, title, Location, and Instructor. After creation of this class the array of object of this class is
initialized and the course.csv file is read and the data from the csv file is stored in the course class
object. In the next part of this assignment IEnumerable course object is created and the query result is
stored, query is created on the data in memory is done with the help of LINQ. The data is fetched for the
rows which has course code value greater than 300 and then the records are sorted by instructor name
and then with the help of foreach loop the query result is printed. As per the requirement one
Instructor.csv file is created with 30 records and then those records are stored in memory by creating
class instructor and array object for that class. Once the class instructor is loaded then the in memory
array of both classes course and instructor are joined by LINQ in order to give Instructor email address.
For joining both the classe join operator is used of LINQ and the filter condition is applied by using
where operator.
This assignment provides complete understanding of LINQ with CSV and provides the wide
understanding of creating database in memory and also query on database and can join database with
the other database and can apply filter on it and fetch the results.
In Assignment 8, the focus is to work on XML hence course CSV file is loaded in the class object of course
and then queries are created on it. There are two types of XML query are created one is the simple
select query with filters and another is the XML join query in which two csv files are read into memory
and then join is applied on it and data is fetched.
In the first part of the question, the class Course is created with the attributes as CourseId, Subject,
Course Code, title, Location, and Instructor. After creation of this class the array of object of this class is
initialized and the course.csv file is read and the data from the csv file is stored in the course class
object. And by using the objects of Class course XML document and then In the next part of this
assignment IEnumerable XML object is created and then dumped in the XML file named course.xml and
saved in the app_folder then query result is stored, query is created on the data in memory is done with
the help of LINQ. The data is fetched for the rows which has course code value greater than 300 and
then the records are sorted by instructor name and then with the help of foreach loop the query result
is printed. As per the requirement one Instructor.csv file is created with 30 records and then those

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Big Data Database: MongoDB
|15
|689
|24

MongoDB:. Database created with the name – “facebookDB”
|7
|478
|21

Assignment 2: C# Application & Test Report.
|26
|2490
|5

Database management system - Assignment
|34
|4683
|127

Logical Data Modeling Assignment PDF
|10
|1481
|131

Systems Analysis and Database Design: Quiz 3
|5
|1091
|43