Visual Basic 2010 How to Program © 1992-2011 by Pearson Education, Inc. All Rights Reserved.

Slides:



Advertisements
Similar presentations
LINQ and Collections An introduction to LINQ and Collections.
Advertisements

Copyright © 2004 Pearson Education, Inc.. Chapter 9 More SQL: Assertions, Views, and Programming Techniques.
Extension Methods, Anonymous Types LINQ Query Keywords, Lambda Expressions Svetlin Nakov Telerik Corporation
Instructor: Craig Duckett CASE, ORDER BY, GROUP BY, HAVING, Subqueries
Programming with Collections Collections in Java Using Arrays Week 9.
A tour of new features introducing LINQ. Agenda of LINQ Presentation We have features for every step of the way LINQ Fundamentals Anonymous Functions/Lambda.
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
Chapter 18 Databases and LINQ Visual C# 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
Databases and LINQ Visual Basic 2010 How to Program 1.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Using the Select Case Statement and the MsgBox Function (Unit 8)
15 Structured Query Language (SQL). 2 Objectives After completing this section, you should be able to: Understand Structured Query Language (SQL) and.
Chapter 3 Single-Table Queries
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Entity Framework MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
Chapter 15: Using LINQ to Access Data in C# Programs.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Arrays.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
5-1 McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved.
Chapter 21 C OQL Copyright © 2004 Pearson Education, Inc.
Chapter 6: The Repetition Structure
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
 Although VERY commonly used, arrays have limited capabilities  A List is similar to an array but provides additional functionality, such as dynamic.
Introduction to LINQ Chapter 11. Introduction Large amounts of data are often stored in a database—an organized collection of data. A database management.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved. 2 Revised by Dr. T. Tran for CSI3140.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 22 - SQL, MySQL, DBI and ADO Outline 22.1 Introduction 22.2 Relational Database Model 22.3 Relational.
Object Oriented Programming Generic Collections and LINQ Dr. Mike Spann
With Microsoft Excel 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Excel 2010.
XML Query: xQuery Reference: Xquery By Priscilla Walmsley, Published by O’Reilly.
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections UTPA – Fall 2011.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
LINQ to DATABASE-2.  Creating the BooksDataContext  The code combines data from the three tables in the Books database and displays the relationships.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
LINQ Language Integrated Query LINQ1. LINQ: Why and what? Problem Many data sources: Relational databases, XML, in-memory data structures, objects, etc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Arrays Outline 6.1Introduction 6.2Arrays 6.3Declaring.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 19 A Ray of Sunshine.
Chapter 11.  Large amounts of data are often stored in a database—an organized collection of data.  A database management system (DBMS) provides mechanisms.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Binding to ListBox and ComboBox Controls List and combo boxes are frequently.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Visual Basic 2010 How to Program
Introduction to LINQ and Generic Collections
 2012 Pearson Education, Inc. All rights reserved.
Instructor: Craig Duckett Lecture 09: Tuesday, April 25th, 2017
Operator Overloading; Class string
Visual Basic 2010 How to Program
LINQ to DATABASE-2.
MIS Professor Sandvig MIS 324 Professor Sandvig
The University of Texas – Pan American
Introduction to LINQ Chapter 11 10/28/2015 Lect 4 CT1411.
Chapter 22 - SQL, MySQL, DBI and ADO
LINQ to DATABASE-2.
Introduction to LINQ Chapter 11.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections UTPA – Fall 2012 This set of slides is revised from lecture slides.
Object Oriented Programming in java
Access: SQL Participation Project
MIS Professor Sandvig MIS 324 Professor Sandvig
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
Chapter 8 JavaScript: Control Statements, Part 2
Presentation transcript:

Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.

 For years, programs that accessed a relational database passed SQL queries as String s to the database management system then processed the results.  Microsoft developed LINQ (Language Integrated Query) to enable you to write query expressions similar to SQL queries that retrieve information from a wide variety of data sources—not just relational databases—using a common syntax that is built into Visual Basic. © by Pearson Education, Inc. All Rights Reserved.

 We use LINQ to Objects in this chapter to query the contents of arrays, selecting elements that satisfy a set of conditions—this is known as filtering.  We also use LINQ to Objects to perform common array manipulations such as sorting an array.  Figure 11.1 shows the types of LINQ queries we cover in this book and how we use them. © by Pearson Education, Inc. All Rights Reserved.

 LINQ allows you to look at collections of data, extract information and manipulate data.  In a LINQ query, you might want to locate all Employee s whose salaries are in a specific range. ◦ To respond to that query, LINQ has to iterate over the data, looking at each item to see if the Employee ’s salary is in range and, if so, selecting that item.  You might also manipulate the data—for example, for each Employee in the result of the preceding query, you could increase the Employee ’s base salary by 4%. © by Pearson Education, Inc. All Rights Reserved.

 Our first LINQ query begins with a From clause, which specifies a range variable ( value ) and the data source to query (the array values).  If the condition in the Where clause evaluates to True, the element is selected—that is, it’s included in the collection of Integer s that represents the query results. © by Pearson Education, Inc. All Rights Reserved.

 For each item in the data source, the Select clause determines what value appears in the results.  The Select clause is usually placed at the end of the query for clarity, though it may be placed after the From clause and before other clauses, or omitted.  If omitted, the range variable is implicitly selected.  The Select clause can transform the selected items—for example, Select value * 2 in this example would have multiplied each selected value in the result by 2. © by Pearson Education, Inc. All Rights Reserved.

 Sorting LINQ Query Results: ◦ The Order By clause sorts the query results in ascending order. ◦ The LINQ queries use the Descending modifier in the Order By clause to sort query results in descending order. ◦ An Ascending modifier also exists but is rarely used, because it’s the default. ◦ You can use the Order By clause only for values that can be compared to one another. ◦ The Order By clause supports values of any type that implements the interface IComparable, such as the primitive numeric types and String. © by Pearson Education, Inc. All Rights Reserved.