LINQ

Views:
 
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Slide 1: 

LINQ : Applicability & Usages Pankaj Ludhiyani pankaj2050@gmail.com pankaj2050@yahoo.com

Agenda : 

Agenda Introduction How LINQ works? Architecture Underline Execution Execution Mode Why LINQ? LINQ to Objects LINQ to SQL LinqDataSource Control Conclusion

Introduction : 

Introduction Language Integrated Query A set of language extensions that allows you to perform queries without leaving the comfort of the programming language (C# or VB) Defines keywords that you use to build query expressions like select, from and where Select, filter, sort, group or transforms the data

How LINQ Works?- Architecture : 

How LINQ Works?- Architecture

How LINQ Works?- Underline Execution : 

How LINQ Works?- Underline Execution var contacts = from c in customers where c.State == "WA" select new { c.Name, c.Phone }; var contacts = customers .Where(c => c.State == "WA") .Select(c => new { c.Name, c.Phone }); Extension methods Lambda expressions Query expressions Object initializers Anonymous types Local variable type inference

How LINQ Works?- Execution Mode : 

How LINQ Works?- Execution Mode Deferred Execution var data = from d in ibEntity.Tourists where d.IsIBMember == true select d; inMemoryData = data.ToList();

How LINQ Works?- Execution Mode (Cont…) : 

How LINQ Works?- Execution Mode (Cont…) Immediate Execution var city = ( from c in inMemoryData select (c.City.ToUpper()) ).Distinct();

Why LINQ? : 

Why LINQ? Unifies the way of accessing data from different data sources. Compile-time checking of all queries, reduces run time errors. Strongly typed. Can be applied in any project layer (UI/Business/Data) Extensive Intellisence/Debugging support. Reusable queries.

LINQ to Objects : 

LINQ to Objects Query can be executed on collections & objects that implements IEnumerable interface. LINQ queries Vs. foreach loops: Concise and readable, especially when filtering multiple conditions. Provides powerful filtering, ordering, and grouping capabilities with a minimum of application code.

LINQ to SQL : 

LINQ to SQL Query data in the SQL Server Database Implicitly transforms LINQ expression into a set of SQL queries Advantages: Flexibility Change Tracking & Batch Updates Less code

LINQ to SQL (Cont…) : 

LINQ to SQL (Cont…) Query the database using LINQ, as well as update/insert/delete data from it. Can be implemented using: LINQ to SQL: context object (DBML) Entity framework (EDMX)

LinqDataSource Control : 

LinqDataSource Control Suitable for rapid application development scenarios Automatically performs data retrieval processes Implementation: Build data model using the DBML/EDMX designer Create the control that will be used to display data Create data source that links the DataContext to data controls

Future Aspects : 

Future Aspects LINQ to Entities Currently under development Uses the ADO.NET provider model, which means it supports any relational database engine that has a suitable provider factory

Conclusion : 

Conclusion It is included in the .NET Framework to provide flexibility & support rapid application development. It satisfies above goals & future version might include extended support & may over come its limitations.

Q & A : 

Q & A

Thank You : 

Thank You Pankaj Ludhiyani pankaj2050@gmail.com pankaj2050@yahoo.com