 Introduction  What is LINQ  Syntax  How to Query  Example Program.

Slides:



Advertisements
Similar presentations
Developer Knowledge Sharing Eric Sun Dec, What programming language did you learn in school and since then? Now, its time to refresh …
Advertisements

Language Integrated Query (LINQ) Martin Parry Developer & Platform Group Microsoft Ltd
LINQ and Collections An introduction to LINQ and Collections.
Extension Methods, Anonymous Types LINQ Query Keywords, Lambda Expressions Svetlin Nakov Telerik Corporation
.NET 3.5 – Mysteries. NetFx Evolution NetFx 1.0 C# 1.0, VB 7.0, VS.NET NetFx 1.1 C# 1.1, VB 7.1, VS 2003 NetFx 2.0 C# 2.0, VB 8.0, VS 2005 NetFx 3.0 C#
C# and LINQ Yuan Yu Microsoft Research Silicon Valley.
Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
What’s new in ASP.NET 3.5? Mike Ormond Developer & Platform Group Microsoft Ltd
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Intro to C# Language Richard Della Tezra IS 373. What Is C#? C# is type-safe object-oriented language Enables developers to build a variety of secure.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
C# 3.0 and LINQ Pavel Yosifovich CTO, Hi-Tech College
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
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.
Discover, Master, InfluenceSlide 1 SQL Server Compact Edition and the Entity Framework Rob Sanders Readify.
Overview of Database Access in.Net Josh Bowen CIS 764-FS2008.
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
Some Basic Database Terminology
LINQ Programming in C# LINQ CSE Prof. Roger Crawfis.
JSP Standard Tag Library
Ihr Logo Data Explorer - A data profiling tool. Your Logo Agenda  Introduction  Existing System  Limitations of Existing System  Proposed Solution.
Databases and LINQ Visual Basic 2010 How to Program 1.
ASP.NET Programming with C# and SQL Server First Edition
Eric Vogel Software Developer A.J. Boggs & Company.
Session 1 - Introduction and Data Access Layer
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC - Models.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Entity Framework MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Putting it all together: LINQ as an Example. The Problem: SQL in Code Programs often connect to database servers. Database servers only “speak” SQL. Programs.
Introduction to LINQ Lecture # 19 August Introduction How do you interrogate/manipulate data? What if you could do the work in a type-safe," string-free.
 Language Integrated Query  Make query a part of the language  Component of.NET Framework 3.5  Shipped with Visual Studio 2008.
How to be a C# ninja in 10 easy steps Benjamin Day.
 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.
C# 3.0 and LINQ Pavel Yosifovich CTO, Hi-Tech College
By: Luis Carranco CIS764 - Fall  What is LINQ  Architecture  How does it work?  Samples/Demo  Why to use LINQ? 2.
BlackBerry Applications using Microsoft Visual Studio and Database Handling.
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections UTPA – Fall 2011.
Satisfy Your Technical Curiosity C# 3.0 Raj Pai Group Program Manager Microsoft Corporation
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
Linq Overview Vincent GERMAIN. Evolution - Rappel Langage  C# 2.0  C# 3.0 (Local type inference, Lambda expression, Method extension,Anonymous type)
Joel Pobar Language Geek Microsoft DEV320 Improve on C# % Backwards Compatible Language Integrated Query (LINQ)
ISYS 512 Business Application Design and Development with.Net David Chao.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
LINQ Language Integrated Query LINQ1. LINQ: Why and what? Problem Many data sources: Relational databases, XML, in-memory data structures, objects, etc.
Ken Casada Developer Evangelist Microsoft Switzerland
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Chapter 11.  Large amounts of data are often stored in a database—an organized collection of data.  A database management system (DBMS) provides mechanisms.
ASP Mr. Baha & Dr.Husam Osta  What is ASP?  Internet Information Services  How Does ASP Differ from HTML?  What can ASP do for you?  ASP Basic.
Introduction to.NET Florin Olariu “Alexandru Ioan Cuza”, University of Iai Department of Computer Science.
Web Database Programming Using PHP
Part 1: Overview of LINQ Intro to LINQ Presenter: PhuongNQK.
ASP.NET Programming with C# and SQL Server First Edition
Visual Basic 2010 How to Program
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2016
LINQ for SQL SQL Saturday May 2009 David Fekke.
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2013
Web Database Programming Using PHP
Language Integrated Query: (LINQ) An introduction
LiNQ SQL Saturday David Fekke.
Module 1: Getting Started
Introduction to LINQ Chapter 11 10/28/2015 Lect 4 CT1411.
Language Integrated Query (LINQ)
Entity Framework Core (EF Core)
Introduction to LINQ Chapter 11.
Introduction to Programming
CS4540 Special Topics in Web Development LINQ to Objects
Presentation transcript:

 Introduction  What is LINQ  Syntax  How to Query  Example Program

 Language INtegrated Query  Released as a part of the.Net Framework 3.5 › November 19, 2007  Supported in the.Net languages › C#, VB.Net

 Used as a universal query language for retrieving data from containers  Appropriate data containers include: › Arrays ›.Net containers such as List and Dictionary › Any IEnumerable collection › SQL Server Database › XML Document

 Resembles SQL in reverse  Introduces new variable type “var” › Compiler determines the type › Still considered strongly typed › Creates “anonymous type” if data type cannot be determined

 Retrieves all integers from listInteger › listInteger is an array of integers › allInt will be an IEnumerable type var allInt = from l in listInteger select l; results of query stored in allInt from statement creates local instance of listInteger in l Select statement specifies what data to take

 Statements between the from statement and select statement are used to refine results returned var greaterThanFive = from l in listInteger where l > 5 select l; Retrieves all integers from listInteger that are greater than 5

 join  orderby … acsending  orderby … decending  group  count  min  Plus many more…

 Using lambda expressions and functions: › var firstPosInt = allInts.First(a => a >= 0); › var posInt = (allInts.Where(a => a >= 0).Select(a => a);

 3 steps in a LINQ query operation: › Obtain the data source › Create the query › Execute the query

 Data Sources can be in memory containers, SQL Server databases or XML documents  In memory data sources need no additional preparation after they have been created  SQL Server Databases must be set up using the DBML Designer in Visual Studio  XML documents must be loaded into an XDocument object

Add new LINQ to SQL Class to project Connect to Database using Server Explorer Drag tables over to designer pane Relationships will be set up automatically

 DataContext will be generated from the DBML diagram  Create DataContext object in code › Name Format: “[NameOfDBMLFile]DataContext” MyDatabaseDataContext AWDatabse = new MyDatabaseDataContext(); //Put query here

 Create new XDocument object from XML File: XDocument xml =

 Syntax is constant for all types of data sources  When querying XML files › Use Elements() and Element() methods to specify tags to query  From x in xmlObject.Elements(“TopTag”) order by (int)x.Element(“id”) select x;

 Query is not executed until the variable is used in code  foreach loop is a common way of accessing query results  Use methods to grab specific elements › Takes first item returned from the query allInt int firstInt = allInt.First();

 Universal syntax when querying in memory data, SQL Servers, or XML files  Syntax resembles SQL  Features make coding quicker and less prone to errors

 Microsoft Corporation. LINQ (Language-Integrated Query). Retrieved October 5, 2013 from  Ferracchiati, F. LINQ for Visual C# New York, NY: Spinger-Verlag New York Inc,  Russo, Marco, and Paolo Pialorsi. Introducing Microsoft LINQ. Redmond, WA: Microsoft,  Guthrie, Scott. "Using LINQ to SQL (part 1)." ScottGu's Blog. Microsoft, 19 May Web. 5 Oct  AdventureWorks2008R2 Database and ObjectDumper Class courtesy of Microsoft › AdventureWorks2008R2 available at › ObjectDumper available in this package at

 Entire project is in compressed file.  Some code is commented out due to needing SQL Express installed and the proper database (which is too large to embed here)