1 / 10

.NET Team

.NET Team. LINQ & ADO.NET Entity Framework. Stefan Dobrev. GM Avaxo Ltd. http://ligaz.blogspot.com. Contents. LINQ – general stuff LINQ Providers ADO.NET Entity Framework. LINQ. Language Integrated Query. DEMO. LINQ in Action. What we saw?. Query expressions. var func =

edita
Download Presentation

.NET Team

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. .NET Team LINQ & ADO.NET Entity Framework Stefan Dobrev GM Avaxo Ltd. http://ligaz.blogspot.com

  2. Contents • LINQ – general stuff • LINQ Providers • ADO.NET Entity Framework

  3. LINQ Language Integrated Query

  4. DEMO LINQ in Action

  5. What we saw? Query expressions varfunc = from l inProgrammingLanguage.GetAll() wherel.Paradigm.HasValue(Functional) select l; Local variable type inference varfunc = ProgrammingLanguage.GetAll() .Where(l => l.Paradigm.HasValue(Functional)) .Select(l => l); Extension methods Lambda expressions Expression Trees

  6. Local Variable Type Inference inti = 5; string s = "Hello"; double d = 1.0; int[] numbers = new int[] {1, 2, 3}; Dictionary<int,Order> orders = new Dictionary<int,Order>(); vari = 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. Extension Methods obj.Foo(x, y)  XXX.Foo(obj, x, y) namespaceITBoxing { public static class Extensions { public static string HasValue( thisProgrammingParadigm paradigm, ProgrammingParadigm value ) { return ( paradigm & value ) != 0 } } } Extension Method Bring extensions into scope usingITBoxing IntelliSense ProgrammingParadigm paradigm = Functional & Imperative; Paradigm.HasValue(Imperative);

  8. Lambda Expressions List<ProgrammingLanguage> langs = ProgrammingLanguage.GetAll(); List<ProgrammingLanguage> cool = langs.FindAll( delegate(ProgrammingLanguage l) { returnl.IsCool; } ); List<ProgrammingLanguage> langs = ProgrammingLanguage.GetAll(); List<ProgrammingLanguage> cool = langs.FindAll(l => l.IsCool); Lambda expression

  9. Expression Trees Code as Data public delegate boolPredicate<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?

More Related