linq

42
www.getgroup.com © Copyright by GET Group 2010 1 Language INtegrated Query

Upload: bassam-gamal

Post on 10-May-2015

333 views

Category:

Technology


1 download

DESCRIPTION

Introduction about .NET LINQ API and all it's components.

TRANSCRIPT

  • 1.www.getgroup.com Copyright by GET Group 20101Language INtegrated Query

2. 2LINQ Introduction. Components. Standard Query Operators Language Extensions Query syntax. Implicitly typed variables. Anonymous types. Object Initializer. Lambda expressions. Extension Methods. Partial Methods.Providers LINQ to Object. LINQ to XML. LINQ to ADO.NET www.getgroup.com Copyright by GET Group 2010LINQ to Dataset. LINQ to SQL. LINQ to Entities.LINQ to ????PLINQ. Performance. Pros and Cons. Examples. 2 3. www.getgroup.com Copyright by GET Group 20103 4. www.getgroup.com Copyright by GET Group 20104 5. www.getgroup.com Copyright by GET Group 20105 6. 6Introduction LINQ APIs unifies the query experience across all sorts of datadomains, allowing developers to learn a single query language thats integrated within the .NET Framework. Query on Sequence to get Element(s).www.getgroup.com Copyright by GET Group 2010 Declarative V.S Imperative Programming. 7. www.getgroup.com Copyright by GET Group 20107Components 8. 8 Restriction AggregateProjectionQuantifiersPartitioningGenerationJoinStandard Query Operators ConcatenationEqualityOrderingConversionGrouping Setwww.getgroup.com Copyright by GET Group 2010Element 9. 9Query syntax Dot notation syntax "Fluent Mixedwww.getgroup.com Copyright by GET Group 2010 Query Expression List Comprehensions or Functional Programming. 10. www.getgroup.com Copyright by GET Group 201010 11. www.getgroup.com Copyright by GET Group 201011 12. 12 Query expressions are not actually evaluated until you iterate over the sequence "Lazy Evaluation. Apply the same LINQ query multiple times to the same container, and rest assured you are obtaining the latest and greatest results. In some cases itd cause performance troubles from accessing data sources so many times.www.getgroup.com Copyright by GET Group 2010Deferred Execution 13. 13Immediate Execution ToArray(), ToList(), ToDictionary(), ToLookUp(). Useful in not accessing data source so many times, buttake memory factor into consideration.www.getgroup.com Copyright by GET Group 2010 Via non-deferred conversion operators. 14. 14Language ExtensionsImplicitly typed variables.Anonymous types.Object Initializer.Lambda expressions.Extension Methods.Partial Methods.Expression Tree.www.getgroup.com Copyright by GET Group 2010Query syntax. 15. www.getgroup.com Copyright by GET Group 201015 16. 16 More efficient if you plan on allowing many potentiallyunimplemented methods in the code. LINQ to SQL and Entity Framework.www.getgroup.com Copyright by GET Group 2010Partial Methods 17. 17 Data representation of a piece of code. Span multiple data domains.www.getgroup.com Copyright by GET Group 2010Expression Tree 18. www.getgroup.com Copyright by GET Group 201018Providers 19. 19LINQ to Objects Perform queries on memory objects. Collections Parallelizable Using PLINQ.www.getgroup.com Copyright by GET Group 2010 Generic and Non Generic. 20. www.getgroup.com Copyright by GET Group 201020 21. www.getgroup.com Copyright by GET Group 201021 22. 22LINQ To Dataset LINQ To Objects. Perform set operations on sequences of DataRow objects. Retrieve and set DataColumn values.DataTable so Standard Query Operators may be called. Copy modified sequences of DataRow objects to a DataTable.www.getgroup.com Copyright by GET Group 2010 Obtain a LINQ standard IEnumerable sequence from a 23. www.getgroup.com Copyright by GET Group 201023 24. 24LINQ To SQL Query a relational Microsoft SQL Server database. Offering you an object model based on available entities. Query this object model by using LINQ queries that are automatically converted into corresponding SQL queries by the LINQ to SQL engine.www.getgroup.com Copyright by GET Group 2010 Working with SQL Server databases in the current world of object-oriented programming languages. 25. www.getgroup.com Copyright by GET Group 201025 26. 26ADO.NET Entity Framework The ADO.NET Entity Framework provides a mapping from the relational database schema to objects. Object-relational mapping (ORM) framework for the .NET Framework. SQL Server and Third-Party Providers. Entity Data Model (edmx). Conceptual Schema Definition Language (CSDL). Entities. Mapping Mapping from .NET classes to relational tables and associations. Mapping Specification Language (MSL). Logical Relational data. Store Schema Definition Language (SSDL).POCO allows you to write your own entity classes in a persistence ignorant fashion.www.getgroup.com Copyright by GET Group 2010 Conceptual .NET classes. 27. www.getgroup.com Copyright by GET Group 201027 28. 28 Looks like LINQ To SQL. Except some syntax differences.www.getgroup.com Copyright by GET Group 2010LINQ To EF 29. 29LINQ To SQL or EF LINQ To SQLEFModelDomain ModelConceptual Data ModelDatabase SupportedSQLVarity of DBQuery LINQ To SQL Data Context LINQ To Entities Object Services Entity ClientFuture Improvements NoYesGenerate database from entity modelNoYesDatabase Schema changed synchronizationNoYeswww.getgroup.com Copyright by GET Group 2010Feature 30. 30 WPF, Silverlight, WWF and WCF make use of XML. System.XML Document. Bottom up LINQ To XML APIS. Top-down codewww.getgroup.com Copyright by GET Group 2010LINQ To XML 31. 31LINQ To ???? LINQ To Events RX Framework. LINQ To Files.www.getgroup.com Copyright by GET Group 2010 LINQ To Form Controls. 32. www.getgroup.com Copyright by GET Group 201032 33. 33PLINQ LINQ query that will perform its workload in parallel (ifpossible). Based on new TPL. Task Parallel LibraryPartitioning the work into tasks, Executing those tasks on threads, Collating the results into a single output sequence. At run time: Parallel, Sequential. Expensive parallel, Inexpensive sequential.www.getgroup.com Copyright by GET Group 2010 Automates all the steps of parallelization, 34. Degree of parallelism. Token Cancellation. With Execution Modewww.getgroup.com Copyright by GET Group 201034 35. www.getgroup.com Copyright by GET Group 201035Performance 36. www.getgroup.com Copyright by GET Group 201036 37. www.getgroup.com Copyright by GET Group 201037 38. www.getgroup.com Copyright by GET Group 201038 39. www.getgroup.com Copyright by GET Group 201039 40. www.getgroup.com Copyright by GET Group 201040 41. www.getgroup.com Copyright by GET Group 201041 42. 42 Professional C# 4 and .NET 4 book. Sams C# Unleashed C# 4 book. Oreilly Csharp 4.0 in a Nutshell book. Apress Pro LINQ book. Microsoft Press Programming LINQ in NET Framework 4 book. Concurrent Programming on Windows book. LINQ To Events. POCO I. POCO II. POCO III. Performance l. Performance ll. Performance lll. Performance IV. LINQ To RX. LINQ Providers List. LINQ To SQL V.S EF.www.getgroup.com Copyright by GET Group 2010References