Most voted "lambda-expressions" questions
A lambda expression is an anonymous function that you can use to create delegates or expression tree types.
Learn more…305 questions
Sort by count of
-
58
votes7
answers20675
viewsWhat are lambda Expressions? And what’s the point of using them?
When I started using LINQ I saw I could use the famous lambda Expressions. Until I know that x => x * x is a lambda Expression, but I could not explain to a colleague what they really are, and…
-
52
votes4
answers12597
viewsWhat are the advantages of Lambda Expressions in Java 8?
Java 8 will be released soon (March 2014) and the main Feature of this version are the Lambda expressions. One could describe, as the question says, what this feature will add in practice to…
-
24
votes2
answers4960
viewsWhat is the difference between "lambda" and LINQ? How to differentiate them in a sentence?
I often see terms like LINQ query and expressions lambda. Then the question arose, What I’m doing is a LINQ query, an expression lambda or both? Ex1: var query = Produtos.Where(p =>…
-
23
votes1
answer1280
viewsDifferences between declarative and imperative form of LINQ
What one way can do that the other can’t? There is a difference in performance? There’s one advantage over the other? Example: using System; using System.Collections.Generic; using System.Linq;…
-
23
votes2
answers2921
viewsWhat does the "=>" operator mean?
I was seeing some solutions in Javascript and in one case I saw this command line: return args.reduce((s, v) => s + v, 0);. But I don’t know what the operator means =>. What is his function?…
-
19
votes1
answer782
viewsCreate classes taking advantage of lambda
After reading this question made by utluiz, I could understand, even if in a more superficial way, a little of the usefulness of the expressions lambda added to JDK 8. However, in addition to the…
-
18
votes2
answers484
viewsIs there an opposite for `contains`?
I have a list: List<int> lista1 = new List<int>(); lista1.Add(1); lista1.Add(2); lista1.Add(3); List<int> lista2 = new List<int>(); lista2.Add(1); lista2.Add(2); To get the…
c# .net entity-framework linq lambda-expressionsasked 9 years, 3 months ago Jedaias Rodrigues 6,718 -
15
votes1
answer357
viewsHow to use Bilge and stream?
I can understand expressions lambdas perfectly in simple cases such as: () -> 42 // Não recebe nada e sempre retorna "42" x -> x*x // Recebe algo e retorna seu quadrado (x,y) -> x + y //…
-
13
votes1
answer1813
viewsWhat is the difference between Action, Predicate and Func
What’s the difference between Action, Predicate and Func in the C#? I would like, if possible, examples of use.
-
13
votes2
answers141
viewsHow to Lambda in Extension Methods with Multiple Lists?
There are the following Objects: public class Objeto1 { public List<Objeto2> PropObj1 {get; set;} } public class Objeto2 { public List<Objeto3> PropObj2 {get; set;} } public class…
c# .net entity-framework linq lambda-expressionsasked 9 years, 3 months ago Jedaias Rodrigues 6,718 -
13
votes2
answers460
viewsWhat is Closure Object and how do I get the anonymous function return as parameter?
Let’s say I have a class, and in that class i have a method, and in a parameter that method it is possible to use a anonymous function thus: Class and method: class Classe { private $exemplo = [];…
-
11
votes2
answers1153
viewsConsulta Lambda
I have the following consultation at T-SQL: SELECT TOP (60) COUNT(*) AS QTD, SUM(Duration) AS Total, AVG(Duration) AS Media, MIN(Duration) AS Menor, LEFT (TextData, 80) AS TextData FROM Traces WITH…
-
11
votes2
answers197
viewsNomenclature or language in lambda
We have that expression: var teste = meucotexto.minhatable.Where(x => x.meu_campo.....) How I read that part x => x.meu_campo Leio x is for x.meu_campo or x of x.meu_campo or something else?…
-
11
votes1
answer800
viewsBuild complex Lambda Expression
I’m trying to build a Lambda Expression that’s a little complex and I’m having difficulties. The goal is this expression: items = items.Where(x => sValues.Any(y => x.Contract_Rates.Select(z…
-
11
votes1
answer469
viewsWhat is the purpose of empty parentheses in a lambda statement?
I created an example of a Lambda statement with no arguments, however, I have doubts regarding the omission of the empty parenthesis () in the statement. Take the example: class Program { public…
-
11
votes2
answers4166
viewsWhat is the difference between the map() and flatMap() functions of Java 8?
What is the difference between the functions map() and flatMap() made available by the API stream java 8?
-
10
votes2
answers16045
viewsForeach or lambda in lists
Which one do I get the best performance to get the value of a given in a list? I do foreach or lambda(when possible, of course)? I can have this: foreach(var i in lista) { var teste = i.NmCampo; }…
-
9
votes1
answer120
viewsDifferences between readonly Func<> and method
Forgetting a little questions like readability, what would be the differences between the following calls? readonly Func = (T1, T2) => { Return default(Tresult); } private readonly Func<int,…
-
9
votes1
answer5672
viewsLeft Join with lambda Groupjoin and with condition
How can I make one left join with some conditions using lambda LINQ expressions? In SQL Server have this query: select usr.Id, usr.FirstName, usr.LastName, ex.Id from User usr left join Exam ex on…
-
9
votes1
answer191
viewsWhat does the [&] operator mean before a function?
I’m trying to read the code of a function that’s defined like this: auto loop = [&](int ntensor, char** data, const int64_t* strides, int64_t n) { ... }; What does the [&] before function?…
-
8
votes2
answers878
viewsWhen to use list comprehension and not filter+lambda?
Good night, you guys. Studying here, I found the functions of List Comprehension and filter+lambda, but both seemed very similar to me on some points... When should I wear List Comprehension instead…
-
8
votes1
answer89
viewsHow do I extract values from an Expression?
Hello. It is possible to extract from an Expression which filters, arrays, etc were used in a query? Example: public class Program { class Produto { public int Id; public string Nome; public…
-
7
votes4
answers2652
viewsDo an update with lambda
I have a query in lambda that returns me a list of data. I wonder how I do to update this table of BD using lambda? Let’s say, I have a table called T_PDV and in it a flag field, where LIDO = 1 and…
-
7
votes1
answer183
viewsLambda with different contexts
Is there any way to join two or more tables using Lambda and two different contexts?
-
7
votes1
answer752
viewsHow to make a sum in Lambda with recursive logic using successor and predecessor?
I’m trying to assemble a Soma with recursive logic using just successor and predecessor in Lambda. But they’re not succeeding... In the case: suc = λx.x+1 ant = λx.x-1 I’ve done something like:…
-
7
votes1
answer586
viewsDo Java 8 streams and streams bring more benefits than concision?
The only benefits I understand in Amble and streams Java 8 is code saving and, as the case may be, better expressing the author’s intention. That’s all? Is there any example of code that uses one of…
java lambda-expressions java-8 functional-programming streamasked 7 years, 4 months ago Piovezan 15,850 -
7
votes2
answers1064
viewsLambda functions in C++, when to use and what are the advantages?
When choosing to use a lambda function or a normal function, and what is the advantage of using a lambda function compared to a normal function? There is the call price of a function in a lambda…
-
7
votes2
answers515
viewsAre Ltenatives for complex conditions in a lambda expression?
With lambda expressions it is possible to filter elements from a collection of objects, creating a data stream according to the criterion passed in the expression for the method filter(), This…
-
7
votes1
answer424
viewsWhat is the difference between using normal methods and Action or Func?
public Action<string> Escrever = (texto) => { Console.WriteLine(texto); }; Might call it that Escrever.Invoke("Algum texto aqui dentro"); VS public string Escrever(string texto) {…
-
7
votes1
answer773
viewsHow to map two LIST properties using the Automapper
Registernewpessoacommand class public class RegisterNewPessoaCommand { public RegisterNewPessoaCommand(PessoaNatureza pessoaNatureza, PessoaFisica pessoaFisica, PessoaJuridica pessoaJuridica,…
-
7
votes2
answers173
viewsSearch range of numbers (string type) with Expression Lambda?
I have this data model and I don’t know how to do the instruction lambda: public class CidadeAbrangencia { [Key] public int CidadeAbrangencia_Id { get; set; } public string CEPInicial { get; set; }…
-
6
votes1
answer13850
viewsJoin with three or more lambda tables
I made this expression using Lambda and 2 tables. var resultado = db.T_TarefaParceiro.Join( db.T_OsParceiro, t1 => t1.IDTarefaParceiro, t2 => t2.IDTarefaParceiro, (t1, t2) => new { t1, t2…
-
6
votes1
answer2820
viewsCompares Datetime field in a lambda only part Date
In this lambda, result will almost always be null, because I gave a Getdate() straight at the bank and when this happens, I record Date and Time. How do I make this lambda pass only Data and compare…
-
6
votes1
answer1827
viewsHow to know which SQL is generated by the ORM Entity Framework?
With the use of ORM, and the practice employed we forget that they generate SQLs and return Objetos (vice versa). How can I find out at runtime the SQL generated by Entity Framework right in the…
sql entity-framework entity-framework-6 lambda-expressions linq-to-entitiesasked 10 years, 5 months ago user6026 -
6
votes1
answer142
viewsConversion error in a query
I made this consultation and in Where is giving this error: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<AnonymousType#1>' to…
-
6
votes1
answer130
viewsTime difference in Linq
I am using Entity Framework, and I have a condition that has not worked very well: .Where(x => ((DateTime.Now - (x.DataInicio.Value == null ? DateTime.Now : x.DataInicio.Value)).TotalMinutes)…
-
6
votes2
answers1543
viewsHow to select fields in a lambda expression query?
Through the select new from LINQ I can select which fields will be displayed in the query, for example: var subCategorias = from s in db.SubCategoria join c in db.CategoriaProduto on s.id_categoria…
-
6
votes2
answers78
viewsIn Java would a variable receive a function like in Javascript?
Example: var x = function (a, b) { return a * b }; Could it be? Or is it a feature of Javascript?
-
6
votes2
answers335
viewsHow do the parameters that LINQ methods receive work?
How the parameters within these methods that receive these parameters work: <TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) An example is the method…
-
5
votes1
answer186
viewsSimulate the same SQL in the Entity Framework with Linq and Lambda?
Having this data model I want to generate a SQL thus in the Entity Framework with Linq and Lambda? Support data SELECT Pessoa.PessoaId, Pessoa.Nome, Pessoa.PessoaPaiId, PessoaPai.Nome AS NomePai,…
-
5
votes1
answer844
viewsFormat date and time and list according to current date
This application has two tables: Students and Occurrences. To show the occurrences I can calmly... Only now I’ve come up with a new business rule: show occurrences by date. So basically it would be…
-
5
votes2
answers957
viewsC# - How to make a lambda filter with more than one field?
My List: public class Carro { public int Ano; public double Valor; } List<Carro> Fiat = new List<Carro>(); Fiat.Add(new Carro {Ano = 2000, Valor = 5000 }); Fiat.Add(new Carro {Ano =…
-
5
votes1
answer673
viewsHow I get the sql that Linq generates by debugging VS2013
How do I get the sql that Linq generates by debugging VS2013? How do I do this? I did it and it didn’t work public static List<MontaArvoreAcao> CriarListaArvoreUn(string _uf, string _cidade,…
-
5
votes1
answer263
viewsHow do I sort Lambda by a List property?
I believe this has been asked before. I researched but did not find. I’m having trouble with this consultation, specifically in charge ThenBy that tries to sort the sub-list of objects. I know it is…
-
5
votes2
answers185
viewsHow to pass a lambda expression as argument of a parameter in a method?
Is there any way to pass a lambda expression as a parameter argument in a method? For example: Private Sub Metodo(Expressao As ?) Lista = Lista.Where(Expressao) End Sub…
-
5
votes1
answer203
viewsWhat are the differences between local functions, delegates and English expressions?
Local functions will be present in C# 7. Given this, I would like to know the main differences between local functions, delegates and expressions Amble.
-
5
votes1
answer201
viewsError when deploying lambda EJB project using glassfish 4
I have in my project two java files First.java. package br.com.bom; import javax.ejb.Stateless; @Stateless public class Primeiro { } Second java. package br.com.bom; import javax.ejb.Stateless;…
-
5
votes2
answers133
viewsHow to filter a Hashmap by returning another Hashmap using Java 8 lambda?
The following code traverses a Set and filters only the objects that the isActive() is true. public Set<InvoiceLineDocument> getActiveLines() { Set<InvoiceLineDocument> activeLines = new…
-
5
votes1
answer159
viewsPurpose of lambda syntax in function/method
In some cases a function/method contains only one line in its scope, see the illustrative example: static int Soma(int a, int b) { return a + b; } Meanwhile, to a new feature in C# 6.0 that allows…
c# function lambda-expressions characteristic-language methodasked 8 years, 4 months ago gato 22,329 -
5
votes2
answers406
viewsTolist vs Typed Tolist
I was reviewing some methods of an ASP.NET MVC project and found some cases where it is used only .ToList() and others in which it is used .ToList<type>() (where type is an object type used in…