Your SlideShare is downloading. ×
0
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Lambda Expressions in C# From Beginner To Expert - Jaliya Udagedara

985

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
985
On Slideshare
0
From Embeds
0
Number of Embeds
45
Actions
Shares
0
Downloads
22
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Works with a variety of database servers (including Microsoft SQL Server, Oracle, and DB2)Includes a rich mapping engine that can handle real-world database schemas and works well with stored proceduresProvides integrated Visual Studio tools to visually create entity models and to auto-generate models from an existing database. New databases can be deployed from a model, which can also be hand-edited for full controlProvides a Code First experience to create entity models using code. Code First can map to an existing database or generate a database from the model.Integrates well into all the .NET application programming models including ASP.NET, Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), and WCF Data Services (formerly ADO.NET Data Services)
  • Reduced development time: the framework provides the core data access capabilities so developers can concentrate on application logic.Developers can work in terms of a more application-centric object model, including types with inheritance, complex members, and relationships. In .NET Framework 4, the Entity Framework also supports Persistence Ignorance through Plain Old CLR Objects (POCO) entities.Applications are freed from hard-coded dependencies on a particular data engine or storage schema by supporting a conceptual model that is independent of the physical/storage model.Mappings between the object model and the storage-specific schema can change without changing the application code.Language-Integrated Query support (called LINQ to Entities) provides IntelliSense and compile-time syntax validation for writing queries against a conceptual model.
  • Reduced development time: the framework provides the core data access capabilities so developers can concentrate on application logic.Developers can work in terms of a more application-centric object model, including types with inheritance, complex members, and relationships. In .NET Framework 4, the Entity Framework also supports Persistence Ignorance through Plain Old CLR Objects (POCO) entities.Applications are freed from hard-coded dependencies on a particular data engine or storage schema by supporting a conceptual model that is independent of the physical/storage model.Mappings between the object model and the storage-specific schema can change without changing the application code.Language-Integrated Query support (called LINQ to Entities) provides IntelliSense and compile-time syntax validation for writing queries against a conceptual model.
  • Reduced development time: the framework provides the core data access capabilities so developers can concentrate on application logic.Developers can work in terms of a more application-centric object model, including types with inheritance, complex members, and relationships. In .NET Framework 4, the Entity Framework also supports Persistence Ignorance through Plain Old CLR Objects (POCO) entities.Applications are freed from hard-coded dependencies on a particular data engine or storage schema by supporting a conceptual model that is independent of the physical/storage model.Mappings between the object model and the storage-specific schema can change without changing the application code.Language-Integrated Query support (called LINQ to Entities) provides IntelliSense and compile-time syntax validation for writing queries against a conceptual model.
  • Transcript

    • 1. Lambda Expressions in C# From Beginner To Expert Jaliya Udagedara
    • 2. What are we going to discuss today? Introduction to Lambda Expressions What are Delegates in C# The Evolution of Delegates in C# Demo 1 - Delegates and Named Methods, Anonymous Methods Lambdas as Generic Delegates Action Func Predicate Lambdas as Callable Entities Lambda Expression Execution Lambdas as Callbacks Demo 2 – Lambda Expressions
    • 3. Introduction to Lambda Expressions Introduced with .NET 3.5/C# 3.0 Supersede anonymous methods Anonymous methods enable you to omit the parameter list Unnamed, inline functions Used wherever delegates are required (input parameters) => expression
    • 4. Expression Lambdas (input parameters) => expression Statement Lambdas (input parameters) => {statement;} Async Lambdas (input parameters) => async {statement;}
    • 5. What are Delegates in C# Delegates are like C++ function pointers Makes it possible to treat methods as entities. Assign to variables Pass as parameters Delegates can be chained together; for example, multiple methods can be called on a single event.Does delegates are exactly same as C++ function pointers? Does methods has to match the delegate type exactly?
    • 6. What are Delegates in C# contd. Delegates are like C++ function pointers but are type safe. Variance in Delegates Covariance permits a method to have return type that is More derived than that defined in the delegate Contravariance permits a method that has parameter types that are less derived than those in the delegate type.
    • 7. The Evolution of Delegates in C# C# 1.0 the only way to declare a delegate was to use named methods. C# 2.0 introduced anonymous methods as a way to write unnamed inline statement blocks that can be executed in a delegate invocation. C# 3.0 introduced lambda expressions, which are similar in concept to anonymous methods but more expressive and concise.
    • 8. Classic Delegate Example btnHelloWorld.Click += new EventHandler(btnHelloWorld_Click);
    • 9. Anonymous Methods btnHelloWorld.Click += delegate(System.Object sender, System.EventArgs e) { … }; Lambda Expressions btnHelloWorld.Click += (sender, e) => { ... };
    • 10. • Anonymous
    • 11. Lambdas as Generic Delegates Generic delegates were new in .NET 2.0 Action Delegates Func Delegates Predicate Delegates
    • 12. Action Delegate Zero, one or more input parameters, and does not return anything. Takes up to 16 parameters Array.ForEach method and List.ForEach Perform an action on each element of the array or list Action<int,int,string>
    • 13. Func Delegate Zero, one or more input parameters, and returns a value Takes up to 16 parameters List.First Func<int,int,string>
    • 14. Predicate Delegate Encapsulates a method that evaluates to True or False Takes one parameter List.Find Func<int>
    • 15. Lambdas as Callable Entities Lambda expressions can be assigned to a delegate variable Lambda expression is executed when the delegate is executed Func<int, string> myFunc = x => { return String.Format("{0}*{0} is {1}", x, x * x); }; Console.WriteLine(myFunc(4));
    • 16. Lambda Expression Execution Lambda expressions are executed when they are called, not when they are constructed Variable value used is the value at execution time
    • 17. Example: Local Variables int y = 0; Func<int, string> myFunc = x => (x + y).ToString(); y = 10; Console.WriteLine(myFunc(5)); Answer?
    • 18. Lambdas as Callbacks Callback “Executable code that is passed as an argument to other code” Passes a function to a function static void DoWork() { CallBack(s => Console.WriteLine(s)); } static void CallBack(Action<string> MyAction) { MyAction("Completed"); }
    • 19. • Lambdas as Generic Delegates • Lambdas as Callable Entities • Lambdas as Callbacks
    • 20. Thank You! http://www.jaliyaudagedara.blogspot.com/

    ×