La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

3/24/2017 3:59 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.

Presentaciones similares


Presentación del tema: "3/24/2017 3:59 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered."— Transcripción de la presentación:

1 3/24/2017 3:59 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

2 Octavio Hernández Mentoring Team Leader Plain Concepts
3/24/2017 3:59 PM LINQ { en profundidad } Octavio Hernández Mentoring Team Leader Plain Concepts © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

3 Agenda Introducción a LINQ Proveedores “predeterminados”
3/24/2017 3:59 PM Agenda Introducción a LINQ Proveedores “predeterminados” Extendiendo LINQ a nuevos tipos de datos y librerías Recomendaciones de uso LINQ después de .NET 3.5 Demos © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

4 3/24/2017 3:59 PM ¿Qué es LINQ? Mecanismo uniforme y extensible para consultar fuentes de datos de diferentes tipos: las expresiones de consulta. Sintaxis basada en nuevas palabras reservadas contextuales. Semántica “enchufable”: los lenguajes no definen la semántica de las nuevas palabras reservadas, sino únicamente un conjunto de reglas para reescribir esas expresiones como cascadas de llamadas a métodos. © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

5 Expresiones de consulta
var delMadrid = from f in DatosFutbol.Futbolistas where f.CodigoClub == “RMA" select new { f.Nombre, f.Edad }; var delMadrid = DatosFutbol.Futbolistas .Where(f => f.CodigoClub == “RMA") .Select(f => new { f.Nombre, f.Edad });

6 Expresiones de consulta
Fuentes de consultas Los datos provienen de cierta fuente, que implementa IEnumerable<T>. Operadores de consulta estándar No todos los operadores tienen un reflejo en la sintaxis de los lenguajes. El patrón LINQ.

7 Operadores Restricción Where Proyección Select, SelectMany Ordenación
OrderBy, ThenBy Agrupación GroupBy Encuentros Join, GroupJoin Cuantificadores Any, All Partición Take, Skip, TakeWhile, SkipWhile Conjuntuales Distinct, Union, Intersect, Except Un elemento First, Last, Single, ElementAt Agregados Count, Sum, Min, Max, Average Conversión ToArray, ToList, ToDictionary Conversión de elementos OfType<T>, Cast<T>

8 Expresiones de consulta
Composicionales, jerárquicas Anidamiento arbitrario. Posibilidad de aplicar operadores adicionales. Declarativas y no imperativas Diga qué usted desea obtener, no cómo. El cómo va por el proveedor. Ejecución diferida Las consultas se ejecutan solo a medida que sus resultados se solicitan.

9 Enchufando la semántica
Tecnología Ensamblado Espacio de nombres LINQ to Objects System.Core.dll System.Linq to XML System.Xml.Linq.dll System.Xml.Linq to DataSet System.Data.DataSetExtensions.dll System.Data to SQL System.Data.Linq.dll System.Data.Linq to Entities System.Data.Entity.dll System.Data.Objects y otros Basados en IEnumerable<T> Basados en IQueryable<T> Silverlight 2.0 .NET 3.5 .NET 3.5 CF

10 LINQ to Objects, XML, SQL, Entities
3/24/2017 3:59 PM { LINQ en profundidad } demo LINQ to Objects, XML, SQL, Entities © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

11 Proveedores Proveedores LINQ C# 3.0 VB 9.0 Otros…
Basados en IEnumerable<T> Basados en IQueryable<T> LINQ to Objects LINQ to XML LINQ to DataSets (el suyo) LINQ to SQL LINQ to Entities (el suyo) Objetos <libro> <titulo/> <autor/> <precio/> </libro> XML BB.DD.

12 Dos clases de proveedores
Basados en IEnumerable<T> Basados en IQueryable<T> Interfaz IEnumerable<T> Ejecución Local, en memoria Usualmente remota Implementación Iteradores Análisis de árboles de expresiones Proveedores LINQ to Objects LINQ to XML LINQ to DataSet LINQ to SQL LINQ to Entities Mis ejemplos LINQ to Pipes LoggingLINQ LINQ to TFS Basados en IEnumerable<T> Basados en IQueryable<T>

13 Extendiendo LINQ Habilite sus API existentes para LINQ
Específicamente para consultas en memoria. Cree métodos extensores que devuelvan un objeto IEnumerable<T>. Desarrolle su propio proveedor de consultas Implemente IQueryable<T>. Analice árboles de expresiones y traduzca nodos a código o a un lenguaje de consultas diferente.

14 Proveedores “a medida”
3/24/2017 3:59 PM { LINQ en profundidad } demo Proveedores “a medida” © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

15 Recomendaciones Analice cuándo y cómo sus consultas se ejecutan
Momento de ejecución. Ejecución local vs. remota. Lugar/capa de ejecución real. Mantenga las consultas dentro de ensamblados No pase expresiones de consulta entre capas.

16 Recomendaciones (2) Cuidado con los tipos anónimos! Aprenda:
Planifique de antemano qué tipos son importantes. No abuse de las proyecciones. Aprenda: A escribir consultas con y sin la sintaxis. Las nuevas características de C# 3.0 Los detalles de la traducción de la sintaxis en llamadas a operadores y cómo funcionan éstos.

17 LINQ más allá de .NET 3.5 Parallel LINQ
Pasa partes de una consulta a diferentes núcleos/procesadores. Proveedores de consultas de terceros: LINQ to Amazon, LDAP, SharePoint, NHibernate, MySql, Flickr, … y mucho más. LINQ 2.0

18 Resumen LINQ es un mecanismo uniforme y extensible para consultar fuentes de datos de diferentes tipos LINQ cambiará la forma en que escribimos código. Más declarativo Muchos menos bucles “a la vista”. Código más fácil de leer y mantener.

19 Más información Centro de desarrollo C# de MSDN
Mi libro, “C# 3.0 y LINQ” Revista dotNetManía

20 {Stand de Plain Concepts}
¡Conócenos! Pregúntanos tus dudas ¡Entra en el sorteo Y podrás ganar alguno de estos libros sobre .NET 3.5!

21 A continuación….. 26 febrero .16:00 Auditorio B Plenaria
Evolución de la Plataforma de Servicios Windows Server 2008 para desarrolladores Hands On Labs en Sala Mónaco y entrega de libro de Visual Studio 2008 y Demos en Zona de Exposición.

22 3/24/2017 3:59 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

23

24 Modelo de Objetos (Datasets/Objetos) Modelo Conceptual (EDM)
Arquitectura Sistemas Externos Capa de Datos SQL Server ADO .NET Data Services (“Astoria”) Lógica de Negocio Modelo de Objetos (Datasets/Objetos) Entidades Relaciones ADO.NET 2.0 Data Provider LINQ to Datasets LINQ to SQL Presentación LINQ to Objects ADO .NET 2.0 Data Providers LINQ to Entities Modelo Conceptual (EDM) Entidades Relaciones ADO.NET Entity Framework (entitySQL) Clientes ADO.NET Entity Framework (Entity Data Model) LINQ to Objects Otras BDs


Descargar ppt "3/24/2017 3:59 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered."

Presentaciones similares


Anuncios Google