Download presentation
Presentation is loading. Please wait.
1
LINQ & ADO.NET Entity Framework
* 1/14/201907/16/96 .NET Team LINQ & ADO.NET Entity Framework Stefan Dobrev GM Avaxo Ltd. (c) 2005 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
2
Contents LINQ – general stuff LINQ Providers ADO.NET Entity Framework
* 1/14/201907/16/96 Contents LINQ – general stuff LINQ Providers ADO.NET Entity Framework (c) 2005 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
3
Language Integrated Query
* 1/14/201907/16/96 LINQ Language Integrated Query (c) 2005 National Academy for Software Development - All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
4
DEMO LINQ in Action
5
Local variable type inference
What we saw? Query expressions var func = from l in ProgrammingLanguage.GetAll() where l.Paradigm.HasValue(Functional) select l; Local variable type inference var func = ProgrammingLanguage.GetAll() .Where(l => l.Paradigm.HasValue(Functional)) .Select(l => l); Extension methods Lambda expressions Expression Trees
6
Local Variable Type Inference
int i = 5; string s = "Hello"; double d = 1.0; int[] numbers = new int[] {1, 2, 3}; Dictionary<int,Order> orders = new Dictionary<int,Order>(); var i = 5; var s = "Hello"; var d = 1.0; var numbers = new int[] {1, 2, 3}; var orders = new Dictionary<int,Order>(); Compiler infers the correct type from the right side
7
Bring extensions into scope
Extension Methods obj.Foo(x, y) XXX.Foo(obj, x, y) namespace ITBoxing { public static class Extensions public static string HasValue( this ProgrammingParadigm paradigm, ProgrammingParadigm value ) return ( paradigm & value ) != 0 } Extension Method Bring extensions into scope using ITBoxing IntelliSense ProgrammingParadigm paradigm = Functional & Imperative; Paradigm.HasValue(Imperative);
8
Lambda Expressions Lambda expression
List<ProgrammingLanguage> langs = ProgrammingLanguage.GetAll(); List<ProgrammingLanguage> cool = langs.FindAll( delegate(ProgrammingLanguage l) { return l.IsCool; } ); List<ProgrammingLanguage> langs = ProgrammingLanguage.GetAll(); List<ProgrammingLanguage> cool = langs.FindAll(l => l.IsCool); Lambda expression
9
Expression Trees Code as Data
public delegate bool Predicate<T>(T item); Expression<Predicate<ProgrammingLanguage>> isCool = l => l.IsCool == true; ParameterExpression l = Expression.Parameter( typeof(ProgrammingLanguage), "l" ); Expression expr = Expression.Equal( Expression.Property(l, typeof(ProgrammingLanguage) .GetProperty("IsCool")), Expression.Constant(true)); Expression<Predicate <ProgrammingLanguage>> isCool = Expression.Lambda <Predicate<ProgrammingLanguage>>(expr, l);
10
LINQ & ADO.NET Entity Framework
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.