How to use linq to query data from object array

Assignment Help Database Management System
Reference no: EM131479883

Lab Assignments

Objectives

In this lab assignment, students will learn:

- How to define LINQ statement
- How to use LINQ to query data from object array

Goals

In this lab assignment, students will demonstrate the abilities to:

- Define LINQ statement
- Use LINQ to query data from object array

1. Create a console application "LINQGradeBook"

2. Add the following class definition:

Public Class GradeBook
Private nameValue As String
Private scoreValue As Integer
Public Sub New(ByVal n As String, ByVal s As Integer)
nameValue = n
scoreValue = s
End Sub
Public Property Name() As String
Get
Return nameValue
End Get
Set(ByVal value As String)
nameValue = value
End Set
End Property

Public Property Score() As Integer
Get
Return scoreValue
End Get
Set(ByVal value As Integer)
scoreValue = value
End Set
End Property
Public Sub displayGradeBook()
Console.WriteLine("Name: " & Name & vbTab & "Score: " & Score)
End Sub

End Class

3. Rename the file "Module1.vb" to "LINQGradeBookTester.vb"

4. Complete the missing code following the comments. You are required to create two LINQ statements which will select specific gradeBook object from a GradeBook objects array.

Option Strict On
Module LINQGradeBookTester

Sub Main()
Dim g1 As New GradeBook("AAA", 70)
Dim g2 As New GradeBook("BBB", 50)
Dim g3 As New GradeBook("CCC", 100)
Dim g4 As New GradeBook("DDD", 80)
'add g1, g2, g3 and g4 in a array and display all student scores
Dim gradeBooks As GradeBook() = {g1, g2, g3, g4}
display(gradeBooks, "Scores for all students: ")

'create a LINQ which get all scores in ascending order and display them.

'create a LINQ which get all students who passed the exam

'display number of passed students, their names and scores

End Sub

'display gradeBook's information
Private Sub display(ByVal gradeBooks As IEnumerable, ByVal header As String)
Console.WriteLine(header)
For Each g As GradeBook In gradeBooks
g.displayGradeBook()
Next
Console.WriteLine()
End Sub

End Module

Here is output:

547_Module Output.jpg

Reference no: EM131479883

Questions Cloud

Show that the ridge estimator is the solution : Show that the ridge estimator is the solution to the problem Minimizeβ Show that the least squares estimate with the ith observation deleted
Define the british interest rate : Use the money market and FX diagrams to answer the following questions about the relationship between the British pound (£) and the U.S. dollar ($).
Create group policies settings to enforce : Create group policies settings to enforce that either Used Disk Space Only or Full Encryption is used when BitLocker is enabled on a drive.
State how each of given variables changes in the short run : Use the money market and FX diagrams to answer the following questions. This question considers the relationship between the Indian rupee (Rs) and the U.S.
How to use linq to query data from object array : How to define LINQ statement? How to use LINQ to query data from object array? Create a console application "LINQGradeBook".
How does overshooting help to resolve the empirical behavior : Is overshooting (in theory and in practice) consistent with purchasing power parity? Consider the reasons for the usefulness of PPP in the short run.
Define relationship between the euro and the us dollar : Use the money market and FX diagrams to answer the following questions. This question considers the relationship between the euro (¤) and the U.S. dollar ($).
Employee counseling programs : Describe the typical activities included in employee counseling programs. Is there really a need for employee counseling?
Research information regarding an rfid system : Research and collect data and information regarding an RFID system that can be integrated into a specific business process to solve a problem.

Reviews

Write a Review

Database Management System Questions & Answers

  Knowledge and data warehousing

Design a dimensional model for analysing Purchases for Adventure Works Cycles and implement it as cubes using SQL Server Analysis Services. The AdventureWorks OLTP sample database is the data source for you BI analysis.

  Design a database schema

Design a Database schema

  Entity-relationship diagram

Create an entity-relationship diagram and design accompanying table layout using sound relational modeling practices and concepts.

  Implement a database of courses and students for a school

Implement a database of courses and students for a school.

  Prepare the e-r diagram for the movie database

Energy in the home, personal energy use and home energy efficiency and Efficient use of ‘waste' heat and renewable heat sources

  Design relation schemas for the entire database

Design relation schemas for the entire database.

  Prepare the relational schema for database

Prepare the relational schema for database

  Data modeling and normalization

Data Modeling and Normalization

  Use cases perform a requirements analysis for the case study

Use Cases Perform a requirements analysis for the Case Study

  Knowledge and data warehousing

Knowledge and Data Warehousing

  Stack and queue data structure

Identify and explain the differences between a stack and a queue data structure

  Practice on topic of normalization

Practice on topic of Normalization

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd