chapter 15 using linq to access data in c programs
Download
Skip this Video
Download Presentation
Chapter 15: Using LINQ to Access Data in C# Programs

Loading in 2 Seconds...

play fullscreen
1 / 23

Chapter 15: Using LINQ to Access Data in C# Programs - PowerPoint PPT Presentation


  • 88 Views
  • Uploaded on

Chapter 15: Using LINQ to Access Data in C# Programs. Understanding Relational Database Fundamentals. Database Holds a file or, more frequently, a group of files that an organization needs to support its applications

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Chapter 15: Using LINQ to Access Data in C# Programs' - merrill


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
chapter 15 using linq to access data in c programs
Chapter 15:

Using LINQ to Access Data in C# Programs

understanding relational database fundamentals
Understanding Relational Database Fundamentals

Microsoft Visual C# 2012, Fifth Edition

  • Database
    • Holds a file or, more frequently, a group of files that an organization needs to support its applications
  • In a database, the files often are called tables because you can arrange their contents in rows and columns
  • Primary key (or key)
    • A value that uniquely identifies a record
understanding relational database fundamentals cont d
Understanding Relational Database Fundamentals (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

understanding relational database fundamentals cont d1
Understanding Relational Database Fundamentals (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

  • Database management software
    • Also called a database management system (DBMS)
    • Allows you to:
      • Create table descriptions
      • Identify keys
      • Add, delete, and update records within a table
      • Arrange records within a table so they are sorted by different fields
      • Write questions that select specific records from a table for viewing
      • Write questions that combine information from multiple tables
      • Create reports that allow users to easily interpret your data
      • Keep data secure by employing sophisticated security measures
understanding relational database fundamentals cont d2
Understanding Relational Database Fundamentals (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

  • Database management software (cont’d.)
    • Establishes and maintains relationships between the columns in tables
      • A group of database tables from which you can make these connections is a relational database
creating databases and table descriptions cont d
Creating Databases and Table Descriptions (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

identifying primary keys
Identifying Primary Keys

Microsoft Visual C# 2012, Fifth Edition

  • The primary key in a table is the column that makes each record different from all others
    • Each primary key must be unique
  • Typical examples of primary keys include:
    • A student ID number in a table that contains college student information
    • A part number in a table that contains inventory items
    • A Social Security number in a table that contains employee information
creating sql queries
Creating SQL Queries

Microsoft Visual C# 2012, Fifth Edition

  • Query
    • Simply a request using syntax that the database software can understand
  • Structured Query Language (or SQL)
    • The most common language that database administrators use to access data in their tables
  • The basic form of the SQL command that retrieves selected records from a table
    • SELECT-FROM-WHERE
      • Example:

SELECT custId, lastName FROM tblCustomer WHERE state = "WI"

creating an access database
Creating an Access Database

Microsoft Visual C# 2012, Fifth Edition

  • Microsoft Office Access
    • A relational database that is part of some versions of the Microsoft Office system
creating an access database cont d
Creating an Access Database (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

creating an access database cont d1
Creating an Access Database (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

understanding linq
Understanding LINQ

Microsoft Visual C# 2012, Fifth Edition

  • LINQ (Language INtegrated Query) Project
    • Provides queries that can be used in C# and Visual Basic
  • In older versions of C#, you could access database data by passing an SQL string to a database object
    • OleDbCommand is a built-in type used to access databases
  • LINQ provides a set of general-purpose standard operators that allow queries to be constructed using syntax that is easy to understand
understanding linq cont d
Understanding LINQ (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

  • The operators defined in LINQ can be used to query arrays, enumerable classes, XML, relational databases, and other sources
  • Some keywords in the LINQ vocabulary:
    • select indicates what to select
    • from indicates the collection or sequence from which data will be drawn
    • where indicates conditions for selecting records
retrieving data from an access database in c
Retrieving Data from an Access Database in C#

Microsoft Visual C# 2012, Fifth Edition

  • Save time and reduce the chance for error by using the built-in tools of the Visual Studio IDE
  • Tasks for adding a database table to a Windows Form project:
    • Drag a DataGridView object from the IDE’s Toolbox onto a Form
      • Next, browse for the project data source and answer a few questions
    • Make a few choices and browse for the database file to add to the project
retrieving data from an access database in c cont d
Retrieving Data from an Access Database in C# (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

retrieving data from an access database in c cont d1
Retrieving Data from an Access Database in C# (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

retrieving data from an access database in c cont d2
Retrieving Data from an Access Database in C# (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

retrieving data from an access database in c cont d3
Retrieving Data from an Access Database in C# (cont’d.)

Microsoft Visual C# 2012, Fifth Edition

using linq queries with an access database table
Using LINQ Queries with an Access Database Table

Microsoft Visual C# 2012, Fifth Edition

You are not required to use the data grid to view database records

You can use a LINQ query to select a collection of data from a table when specific criteria are met

ad