LINQ Providers

  • View
    30

  • Download
    0

Embed Size (px)

DESCRIPTION

LINQ Providers. Or why .NET rules, and Java doesn’t. Branimir Giurov. SofiaDev.org UG Lead, C# MVP Freelance Software Developer. www. sofiadev.org. Contents. typeof ( linq ) How does it work? Lambda, extension methods, iterators. typeof ( linq ). - PowerPoint PPT Presentation

Text of LINQ Providers

  • LINQ ProvidersOr why .NET rules, and Java doesnt Branimir GiurovSofiaDev.org UG Lead, C# MVPFreelance Software Developerwww.sofiadev.org

  • Contentstypeof(linq)How does it work?Lambda, extension methods, iterators

  • typeof(linq)

  • .NET Language Integrated QueryC# 3.0VB 9.0OthersLINQ to ObjectsLINQ to SQLLINQ to XMLLINQ to EntitiesLINQ to Datasets

  • typeof(linq)LINQ to ObjectsLINQ to SQLLINQ to XMLLINQ to DatasetsLINQ to EntitiesLINQ to Windows SearchLINQ to GoogleLINQ to SharepointLINQ to nHibernate

  • LINQ to ObjectsQuery language over collections of objectsStandard SQL-like set of query operators, including joins and groupingNew query operators can be added, fully extensible (extension methods)Intellisense and compiler syntax checking support in Visual Studio

  • LINQ to ObjectsHow to query an array of int?

    public void Linq1() { int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; var lowNums = from n in numbers where n < 5 select n; Console.WriteLine("Numbers < 5:"); foreach (var x in lowNums) { Console.WriteLine(x); } }

  • LINQ to SQLWrite queries in any .NET language to retrieve and manipulate data from SQLUse FK constraints for defining relations of data without joinsJoin in code on any column that has no FK definedUse FKs to query/modify data in SQL DBCall SubmitChanges() when youre doneCurrently supports SQL 2000 & 2005System.Date.Linq.SqlClient.Sql2000ProviderSystem.Date.Linq.SqlClient.Sql2005Provider

  • DEMOLINQ to SQLToString()Modifying QueriesMapping StylesMapping Tools

  • LINQ to XMLLINQ to XML is a new way to construct, write and read XML data in the .NET language of the developers choiceSimplifies working with XML No more XPath or XSLTNot a replacement for DOM or any of the current XML libsSupports writing Query Expressions Can be combined with any of the other LINQ technologiesSupports SAX-style reading/writing of documents with the use of XStreamingElementDiffered execution

  • LINQ to XMLCombining it with other LINQ technologies makes life easier

    XElement xml = new XElement("contacts", new XElement("contact", new XAttribute("contactId", "2"),new XElement("firstName", "Barry"),new XElement("lastName", "Gottshall") ), new XElement("contact", new XAttribute("contactId", "3"), new XElement("firstName", "Armando"), new XElement("lastName", "Valdes") ) );

  • LINQ to XMLResult from previous example:

    Barry Gottshall Armando Valdes

  • LINQ to DataSet(s)Allows developers to query existing DataSet sources within applicationsOffline, still uses IQueryable approach2 types of queries, depending on use of typed/un-typed datasetsUse LINQ in current applications without re-writing using LINQ to SQLBi-directional: LINQ Sequence -> DataTable -> LINQ Sequence support

  • How Does it Work?Depends on if the type is {0} or notIQueryableSystem.Linq.Queryable (System.Data.Linq.DataQuery)SQLEntityDatasetsThe extension methods build an expression treeIf not, then check if it is a IEnumerableSystem.Linq.IEnumerableObjectsXMLThe extension methods run the query

  • How Does it Work?.NET Language Integrated QueryC# 3.0VB 9.0OthersLINQ to ObjectsLINQ to SQLLINQ to XMLLINQ to EntitiesLINQ to Datasets

  • How Does it Work?Extension methods for the from/select/where/groupby keywordsLambda expressionsExpression tree for building & pre-compiling the statement that will run on a IQueryablep=> p.CompanyName.StartsWith(A)Iterators for the in-memory queries (IEnumerable)foreach on an IEnumerable

  • Whats Next?PLINQParallel FX LibraryIParallelEnumerableCTP is availableSupport for 3rd party DB engines

    **07/16/96(c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.**##**07/16/96(c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.**##**07/16/96(c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.**##