Damien Guard (BSc, MBCS) Guernsey Software Developer Forum Language Integrated Query:

Slides:



Advertisements
Similar presentations
The Microsoft Technical Roadshow 2007 Language Enhancements and LINQ Daniel Moth Developer & Platform Group Microsoft Ltd
Advertisements

Language Integrated Query (LINQ) Martin Parry Developer & Platform Group Microsoft Ltd
Deep Dive into LINQ Eran Sharabi.NET Development Team Leader JohnBryce Training
© Logica All rights reserved ADO vNext LINQ LINQ to SQL Entity Framework Freek Leemhuis
ASP.NET 3.5 New Features. 2 Agenda What's New in.NET Framework 3.5? Visual Studio 2008 Enhancements LINQ (Language Integrated Query) New ASP.NET Server.
C# 3.0 & LINQ Raimond Brookman – IT Architect
LinqToSharePoint SandBoxed Solution Shakir Majeed Khan
Damien Guard (BSc, MBCS) Guernsey Software Developer Forum Language Integrated Query:
.NET Framework V3.5+ & RESTful web services Mike Taulty Developer & Platform Group Microsoft Ltd
Building a Complete Web Application Using ASP.NET 3.5 & Visual Studio 2008 (Part 1 of 2) Jeff King Program Manager Microsoft Corporation
The Microsoft Technical Roadshow 2007 Advances for Data in VS “Orcas” Mike Taulty Developer & Platform Group Microsoft Ltd
© Copyright SELA Software & Education Labs Ltd Baruch Hirsch St. Bnei Brak Israel Microsoft Entity Framework v1.1 over Oracle Database Erez.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
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.
Introduction to ADO Entity Framework ir Denis VOITURON Source:
LINQ Programming in C# LINQ CSE Prof. Roger Crawfis.
1 Entity Framework Introduction. Outline Goals of Entity Framework 2.
 Introduction  What is LINQ  Syntax  How to Query  Example Program.
Slides from Gang Luo, Xuting Zhao and Damien Guard
Reflection IT LINQ & Entity Framework Fons Sonnemans (Trainer)
Entity Framework Code First End to End
LINQ, An IntroLINQ, An Intro Florin−Tudor Cristea, Microsoft Student Partner.
Eric Vogel Software Developer A.J. Boggs & Company.
NHibernate in Action Web Seminar at UMLChina By Pierre Henri Kuaté 2008/08/27
Intro to C#.net and EF Ilan Shimshoni. The Three Faces of ADO.NET The connected layer – Directly connecting to the DB The disconnected layer – Using datasets.
ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 4. 2 Overview Data Binding Data Providers Data Connection Data Manipulations.
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.
LINQ and C# 3.0 Mads Torgersen Program Manager for the C# Language Microsoft Corporation.
LINQ: It’s Not Your Father’s Data Access Denny Boynton Anheuser-Busch Companies.
The.NET Language Integrated Query Project Anders Hejlsberg TLN306 Technical Fellow Microsoft Corporation.
 Language Integrated Query  Make query a part of the language  Component of.NET Framework 3.5  Shipped with Visual Studio 2008.
OR Mapping Object relational mapping (ORM, O/RM, and O/R mapping)
Oct * Brad Tutterow. VS 2008.NET 3.5LINQ Entity Framework  The ADO.NET Entity Framework is part of Microsoft’s next generation of.NET technologies.
C# 3.0 and LINQ Pavel Yosifovich CTO, Hi-Tech College
Copyright © 2004 J. Ambrose Little Introduction to Object-Relational Mapping for.NET.
JDS – VB.NET Skill Session Fall 2004 Presented by YUHAO LIN.
AUC Technologies LINQ (Language Integrated Query) LINQ Presented By : SHAIKH SHARYAR JAVED Software Engineer (Daedalus Software Inc.) Technology Teacher.
Language Integrated Query (LINQ). Data Access Programming Challenges Developers must learn data store-specific query syntax Multiple, disparate data stores.
1 ADO.NET Data Services Mike Taulty Developer & Platform Group Microsoft Ltd
Applied Linq Putting Linq to work Introducing… Class-A Kennisprovider Microsoft development Training Coaching Alex Thissen Trainer/coach.
LINQ & PLINQ (Parallel) Language Integrated Query.
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections UTPA – Fall 2011.
HNDIT Rapid Application Development
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)
LINQ Language Integrated Query LINQ1. LINQ: Why and what? Problem Many data sources: Relational databases, XML, in-memory data structures, objects, etc.
Language Integrated Query Mike Taulty Developer & Platform Group Microsoft Ltd
2 Behind every great site, there is great data Eric Nelson Developer Evangelist Microsoft UK
Data Access Methodologies: When to choose what (ADO.NET, Entity Framework, WCF Data Services) Wriju Ghosh Lead Partner Consultant, Microsoft.
 A database is an organized collection of data  A database management system (DBMS) provides mechanisms for storing, organizing, retrieving and modifying.
Introduction to Entity framework
Part 1: Overview of LINQ Intro to LINQ Presenter: PhuongNQK.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to Entity Framework
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
Language Integrated Query: (LINQ) An introduction
LiNQ SQL Saturday David Fekke.
Databases Intro (from Deitel)
9/20/2018 2:13 PM Visual Studio развитие технологий доступа к данным на платформе Microsoft.NET Роман Здебский Эксперт по технологиям разработки.
ADO.NET Entity Framework
ADO.NEXT Advances in Data Access for 2008
An Introduction to Entity Framework
Language Integrated Query (LINQ)
INFO 344 Web Tools And Development
Технологии доступа к данным на платформе Microsoft.NET
CS4540 Special Topics in Web Development LINQ to Objects
Presentation transcript:

Damien Guard (BSc, MBCS) Guernsey Software Developer Forum Language Integrated Query: An introduction Updated and revised by MHA, Nov. 2014

What is LINQ? Language Integrated Query (LINQ) Make query a part of the language Component of.NET Framework 3.5 Tool support from Visual Studio Works with C#, VB.NET etc.

Query without LINQ Objects using loops and conditions foreach(Customer c in customers) if (c.Region == "UK")... Databases using SQL SELECT * FROM Customers WHERE Region='UK' XML using XPath/XQuery

ADO without LINQ SqlConnection con = new SqlConnection(...); con.Open(); SqlCommand cmd = new * FROM Customers WHERE c.Region con ); "UK"); DataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string name = dr.GetString(dr.GetOrdinal("Name")); string phone = dr.GetString(dr.GetOrdinal("Phone")); DateTime date = dr.GetDateTime(3); } dr.Close(); con.Close();

Query with LINQ C# var myCustomers = from c in customers where c.Region == "UK" select c; VB.NET Dim myCustomers = From c In customers _ Where c.Region = "UK" _ Select c

More LINQ queries C# var goodCusts = (from c in db.Customers where c.PostCode.StartsWith("GY") orderby c.Sales descending select c).Skip(10).Take(10); VB.NET Dim goodCusts = (From c In db.Customers _ Where c.PostCode.StartsWith("GY") _ Order By c.Sales Descending _ Select c).Skip(1).Take(10)

Advantages Unified data access Single syntax to learn and remember Strongly typed Catch errors during compilation IntelliSense Prompt for syntax and attributes Bindable result sets

Architecture OthersC#VB.NET.NET Language Integrated Query (LINQ) LINQ to SQL LINQ to Objects LINQ to XML LINQ to Datasets LINQ to Entities LINQ data source providers ADO.NET support for LINQ + many other 3 rd party providers!

LINQ to Objects C# int[] nums = new int[] {0,4,2,6,3,8,3,1}; double average = nums.Take(6).Average(); var above = from n in nums where n > average select n; VB.NET Dim nums() As Integer = {0,4,2,6,3,8,3,1} Double average = nums.Take(6).Average() Dim above = From n In nums _ Where n > average _ Select n

LINQ to Objects Query any IEnumerable source Includes arrays, List, Dictionary... Many useful operators available Sum, Max, Min, Distinct, Intersect, Union Expose your own data with IEnumerable or IQueryable Create operators using extension methods

LINQ operators AggregateConversionOrderingPartitioningSets Aggregate Average Count Max Min Sum Cast OfType ToArray ToDictionar y ToList ToLookup ToSequenc e OrderBy ThenBy Descending Reverse Skip SkipWhile Take TakeWhile Concat Distinct Except Intersect Union and many others

LINQ to SQL Object-relational mapping Records become strongly-typed objects Data context is the controller mechanism Facilitates update, delete & insert Translates LINQ queries behind the scenes Type, parameter and injection safe

Database mapping VS 2008 designer or SQLMetal command Map tables & fields to classes & properties Generates partial classes with attributes Each record becomes an object Data context represents the database Utilise tables, views or stored procedures

Modifying objects Update Set object properties Delete context.Table.DeleteOnSubmit(object) Insert context.Table.InsertOnSubmit(object) Commit changes back context.SubmitChanges() Transactional - all or nothing

Demo of LINQ to SQL ( this will come later – see agenda! ) Topic: “LINQ to Database”

Additional providers Relational data NHibernate, MySQL, Oracle, PostgreSQL Web services RDF, Flickr, Amazon, WebQueries Custom LDAP, Google Desktop, SharePoint, TerraServer maps

Future developments Entity Framework EF is an object-relational mapper (ORM) that enables.NET developers to work with relational data using domain-specific objects. Blinq Scaffold web UI for list/view/update pages PLINQ Parallel query processing over many CPUs SyncLINQ & Continuous LINQ Updated results via INotifyCollectionChanged

Limitations LINQ Only defines query, not update or context LINQ To SQL Mapping is set at compile time “fixed”: LINQ Dynamic Query Library Cannot mix mapped and unmapped properties in a single query.

.NET features used.NET Framework 2.0 Partial classes (mapping).NET Framework 3.5 Anonymous types (shaping) Extension methods (query operators) Type inference (var keyword) Lambda expressions (query syntax)

Alternatives for.NET NHibernate Castle MonoRail / ActiveRecord SubSonic Code generation tool + templates CodeSmith, MyGeneration, LLBLGen/Pro + NetTiers, DooDads, roll your own...

Questions & answers