Agenda
What is LINQ?
What is a Lambda Expression?
Lambda in Standard Query Operators
Type Interface
Variable Scope
Expression Tree
Conclusion
What is LINQ?
What is LINQ?
LINQ successfully combines queries in C# and Visual
Basic using a series of extensions.
The query language developed by Microsoft has been
completely incorporated.
LINQ is an abbreviation that stands for Language
Integrated Query.
It allows you to access data from in-memory objects,
databases, XML documents, and many other sources.
What is a Lambda Expression?
Syntax:
(Input parameters) ⇒ Statement block
What is a Lambda Expression?
Lambda expressions are the executable element of
LINQ equations that convert logic at runtime to pass
to the data source.
Async lambdas are lambda expressions that
incorporate asynchronous processing using the
async keyword.
Syntax:
Func<Task<string>> getWordAsync = async()⇒ “Simplilearn”;
Lambda in Standard
Query Operators
Lambda in Standard Query Operators
Using a lambda expression, the developer has
utilised the 'Where' operator to recover the odd
values from the provided list.
Lambda expressions let developers to input their
own logic into the basic query operators.
The demand evaluates a lambda expression and
operates on each element in the input sequence,
not the complete sequence.
Type Inference
Type Inference
In C#, type inference may be utilised in many
circumstances without defining the types directly.
In a lambda expression, type inference only works when
each type is defined by the compiler.
The compiler uses type inference to deduce that x is an
integer by looking at the Transformer's argument type.
Syntax:
delegate int Transformer (int i);
Variable Scope
Variable Scope
Variables scope within a lambda expression are not
supposed to be seen in an outer procedure.
A captured variable cannot be garbage collected
unless the delegate addressing it becomes eligible for
garbage collection.
A return statement within a lambda expression cannot
affect the return of an enclosing procedure.
Expression Tree
Expression Tree
Expression trees are data structures in which each
node represents an expression or a binary
operation (like x<y).
Statement lambdas of two or three statements are
also available but are not utilized to build
expression trees.
A return statement must be in a lambda.
Syntax:
(Params)  {Statements}
Conclusion
Conclusion
A lambda expression can contain parameters and can return a value.
Conclusion
A lambda expression can specify parameters in a number of different ways.
Conclusion
A lambda expression with only one statement requires no curly brackets, however with several
statements, curly brackets and a return value are required.
Conclusion
Closure allows lambda expressions to access variables outside the lambda expression block. To
avoid any issues, use closure with caution.
Conclusion
No hazardous code can be run inside a lambda expression.
Conclusion
Lambda expressions should not be used left of the operator.
C#-LINQ-and-Lambda-Expression

C#-LINQ-and-Lambda-Expression

  • 2.
  • 3.
    What is LINQ? Whatis a Lambda Expression? Lambda in Standard Query Operators Type Interface Variable Scope Expression Tree Conclusion
  • 4.
  • 5.
    What is LINQ? LINQsuccessfully combines queries in C# and Visual Basic using a series of extensions. The query language developed by Microsoft has been completely incorporated. LINQ is an abbreviation that stands for Language Integrated Query. It allows you to access data from in-memory objects, databases, XML documents, and many other sources.
  • 6.
    What is aLambda Expression?
  • 7.
    Syntax: (Input parameters) ⇒Statement block What is a Lambda Expression? Lambda expressions are the executable element of LINQ equations that convert logic at runtime to pass to the data source. Async lambdas are lambda expressions that incorporate asynchronous processing using the async keyword. Syntax: Func<Task<string>> getWordAsync = async()⇒ “Simplilearn”;
  • 8.
  • 9.
    Lambda in StandardQuery Operators Using a lambda expression, the developer has utilised the 'Where' operator to recover the odd values from the provided list. Lambda expressions let developers to input their own logic into the basic query operators. The demand evaluates a lambda expression and operates on each element in the input sequence, not the complete sequence.
  • 10.
  • 11.
    Type Inference In C#,type inference may be utilised in many circumstances without defining the types directly. In a lambda expression, type inference only works when each type is defined by the compiler. The compiler uses type inference to deduce that x is an integer by looking at the Transformer's argument type. Syntax: delegate int Transformer (int i);
  • 12.
  • 13.
    Variable Scope Variables scopewithin a lambda expression are not supposed to be seen in an outer procedure. A captured variable cannot be garbage collected unless the delegate addressing it becomes eligible for garbage collection. A return statement within a lambda expression cannot affect the return of an enclosing procedure.
  • 14.
  • 15.
    Expression Tree Expression treesare data structures in which each node represents an expression or a binary operation (like x<y). Statement lambdas of two or three statements are also available but are not utilized to build expression trees. A return statement must be in a lambda. Syntax: (Params)  {Statements}
  • 16.
  • 17.
    Conclusion A lambda expressioncan contain parameters and can return a value.
  • 18.
    Conclusion A lambda expressioncan specify parameters in a number of different ways.
  • 19.
    Conclusion A lambda expressionwith only one statement requires no curly brackets, however with several statements, curly brackets and a return value are required.
  • 20.
    Conclusion Closure allows lambdaexpressions to access variables outside the lambda expression block. To avoid any issues, use closure with caution.
  • 21.
    Conclusion No hazardous codecan be run inside a lambda expression.
  • 22.
    Conclusion Lambda expressions shouldnot be used left of the operator.