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

  Create an entity diagram showing all your attributes

Create an entity/relationship diagram (ERD) showing all your entities, attributes, and relationships. Sketch your ERD by hand or use a drawing program. Your diagram must beon a single page.

  Web forms and database interaction assignment description

Web Forms and Database Interaction Assignment description, public static bool SavePersonnel(string Database, string FirstName, string LastName, string PayRate, string StartDate, string EndDate)

  Part a sql queriesuse the classicmodels database

part a sql queriesuse the classicmodels database classicmodels.sql from the itc114 interact resources site.answer the

  Select the primary key from the candidate keys

How do you select the primary key from the candidate keys? How do foreign keys relate to candidate keys? Provide examples from either your workplace or class assignments.

  Explain which transaction satisfy two-phase locking protocol

Please briefly explain whether the following schedule has a deadlock. Your grade depends on both your answer and explanation and please briefly explain which transactions satisfy two-phase locking protocol and which don't.

  Draw the uml class diagram using powerpoint

Draw the UML class diagram using PowerPoint (PPT) or any other graphical editing tool, then implement the code in Java. Be sure your code compiles and runs as expected.

  Determine cost of least expensive part in part table

Write a query to determine the cost of the least expensive part in the part table? Format the returned price in dollars and cents using the correct function.

  Find the clients living in kansas city

Find the clients living in Kansas City. Include the client's Client No., Clast name, Cfirst name, Caddress, the name(s) of their pet(s), and their respective Quoted Prices. Save the query as CLIENTS in KANSAS CITY.

  Write down a sql statement to display the major of students

query 1 write a sql statement to display students first and last name. query 2 write a sql statement to display the

  Design a nested menus interface for a check-in

Design a nested menus interface for a check-in and check-out hotel reservation system that can be used internationally.

  Create the customer profile table with relevant fields

You are required to design the following tables in a database for the company and create the Customer Profile Table with relevant fields for capturing information related to the customers such as customers' address, phone number, payment method a..

  Raw data representation and interpretation

Raw Data Representation and Interpretation

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