1 / 11

CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises

This chapter covers exercises on the relational database model, retrieving and manipulating data using LINQ, and data binding between GUI controls and databases.

rlynn
Télécharger la présentation

CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539 xiang.lian@utrgv.edu

  2. Objectives • In this chapter, you will do some exercises about: • The relational database model • LINQ to retrieve and manipulate data from a database • Data binding to display or update data between GUI controls and databases

  3. Multiple Choice • The international standard database query language is ________. • A. LINQ B. C# C. SQL D. XML • A table in a relational database consists of ____ and ____ in which values are stored. • A. rows … columns B. keys … records C. array … collection D. bits and characters • The _____uniquely identifies each row in a relational database table. • A. foreign key B. attribute C. primary key D. view • The _______control displays data in a table that correspond to rows and columns of the underlying data source. • A. DataSource B. DataContext C. DataBinding D. Database

  4. Multiple Choice (cont'd) • A relational database can be manipulated in LINQ to SQL via a(n) _________ object, which contains properties for accessing each table in the database. • A. LINQ to SQL B. SQL to LINQ C. SQL to XML D. Database • Merging data from multiple relational database tables is called _____ the data. • A. selecting B. projecting C. where D. joining • A(n) _________is a column (or groups of column) in a relational database table that matches the primary-key column (groups of column) in another table. • A. foreign key B. attribute C. primary key D. view • The _______ property of a control specifies where it gets the data it displays. • A. DataSource B. DataContext C. DataBinding D. Database

  5. Multiple Choice (cont'd) • The optional _____ clause in a SQL SELECT query specifies selection criteria. • A. WHERE B. SELECT C. FROM D. ORDER BY • The optional _____ clause in a SQL SELECT query specifies the order in which rows • A. WHERE B. SELECT C. FROM D. ORDER BY

  6. True / False Statements • Providing the same value for a foreign key in multiple rows causes the DBMS to report an error. • Providing a foreign-key value that does not appear as a primary-key value in another table is an error. • The result of a SQL query can be sorted in ascending or descending order. • LINQ to SQL automatically saves changes made back to the database.

  7. True / False Statements (cont'd) • Only SQL UPDATE statement can change the data in a database. • SQL SELECT queries can merge data from multiple relational database tables. • A SQL DELETE statement deletes only one row in a relational table.

  8. Display Table • In the example of Books database in this chapter, create an LINQ query that changes the DataSource property of authorBindingSource to contain only the specified authors "Xiang Lian". • private BooksDataContext database = new BooksDataContext(); • authorBindingSource.DataSource = …

  9. Happy Thanksgiving Day!

More Related