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
-
3
votes2
answers67
viewsHow to avoid the sum of items in my lambda. Result is not expected
I got this lambda: [Route("getliberaitens/{id}")] public List<LiberacaoItensDTO> GetLibItems(double id) { var lista = contexto.Liberacoes .Join ( contexto.ItensLibs, t1 => t1.IdOrcamento,…
-
3
votes1
answer358
viewsSort lists with multiple parameters using lambda expression
Given the class Ponto, the function ordenar sort the list elements by the following criteria: first value in x, afterward y and finally value in z. Okay, the code works. But I’d like to understand…
-
3
votes2
answers1207
viewsLeft Join with three or more lambda tables
I have the following consultation on SQL: select e.idEstado, e.txtNomeEstado, e.txtSiglaEstado, c.idCidade, c.txtNomeCidade, de.txtH1, de.txtTitulo, de.txtDescricaoEstado, de.txtDescription from…
-
3
votes2
answers2574
viewsLINQ using function inside select new{} with lambda Expression
I am assembling a select, with the Entity Framework, which needs to "create a column" according to 4 criteria. I am trying this way: IQueryable<ImoveisDTO> Resultado = ctx.Imoveis.Select(ib…
-
3
votes2
answers825
viewsLambda in Java 8 launching Exception
I have the following problem. I need to perform a user update process and your group, and to perform the change I perform the user search, validating if it exists and soon after, I look for the…
-
3
votes1
answer104
viewsHow to create an Object in a Linq.Expressions.Expression and add properties dynamically to it in C#
Hi, I’m creating a library of DataAnnotations to extend Entityframeworkcore with structures that today only exist using Fluentapi. In one of them, I’m trying to recreate this block of Fluentapi:…
-
3
votes1
answer75
viewsWrong Linq expression when avoiding repetitions on a List
I’m trying to avoid duplicate data before giving a set value. I have a class Player that has itself a property called NickName, this class is inserted in List. Player class: public class Player {…
-
3
votes1
answer77
viewsHow to express a predicate of equality in Java?
I have the following expression: final String idStatusAutorizada = ...; // valor constante return pendencias.stream() .map(TipoBlocCarga::getIdStatus) .anyMatch(idStatusPendencia ->…
-
3
votes2
answers220
viewsAWS Lambda Function ( versioning and integration with API Gateway )
Problems with lambda versioning: I have a lambda function where I use environment variables. This function is executed by an endpoint through the Gateway API ( aws ) I have 3 stages of the same…
-
3
votes1
answer101
viewsImprove performance in iteration
I have a C# method that receives a List<string> and I must return a string with the list of members of the List<string> ordered by number of occurrences and then alphabetically. I did…
-
2
votes1
answer66
viewsExpression inside a lambda gives error
I created a lambda and tried to create an expression or other. With or(||) it didn’t work. Then, instead of || I added Where. Is that right? This way now: var resultado = db.T_CRM_StatusPDV .Where(a…
-
2
votes1
answer1300
viewsCalculate date difference and compare with integer field in lambda expression
I have a data field (Datetime) and also an integer field. I need to make the difference between this date field and today’s date (Datetime.Now) and compare whether it is larger or smaller than my…
-
2
votes2
answers495
viewsLambda Expression X
Speaking in terms of overall performance (speed, integrity and etc...), using English expressions to query database, is better in the above terms or depends on?
-
2
votes1
answer741
viewsManipulating Listview C#
I have a Listview that displays the data on the screen and has several rows and columns. For example: Cl1 | Cl2 | Cl3 L1 aa | bb | cc L2 ab | bc | cd L3 ac | bd | ce I wonder, if you have any c#…
-
2
votes2
answers72
viewsExpression does not bring results, but there is data
This is my direct sql query. select c.de_cnpj, c.DT_TransacaoV from T_CRM_StatusPDV c join T_PDV p on c.DE_CNPJ = p.CNPJ where DATEDIFF(DAY,c.DT_TransacaoV,GETDATE()) > 45 This is my lambda…
-
2
votes1
answer116
viewsPlace a decision control inside a lambda expression
I’m building this consultation: private List<string> pegaInformacaoParceiro(string _osparceiro, string _cnpj) { List<string> lista = new List<string>(); WEBEntities db = new…
-
2
votes1
answer2885
viewsJava 8 - Collecting elements from a list
Good morning. I would like to collect specific elements from a list. I could do the Java 7 style, but I’m curious to know how I would do in the Java 8 style. For example: [[1, 2, 3], [1, 2, 3], [4,…
-
2
votes1
answer3027
viewsAnonymous function returns: syntax error, Unexpected T_FUNCTION
When trying to use this function: <?php echo preg_replace_callback('~-([a-z])~', function ($match) { return strtoupper($match[1]); }, 'hello-world'); PHP returns this error: Parse error: syntax…
-
2
votes1
answer1223
viewsComplex query when passing parameters
I need to make a query, but I’m having a hard time. I have 5 filters on the page. Three of them come from three dropdown (select). I can only consider select if the text in them is different from…
-
2
votes1
answer601
viewsHow to transform Amble expressions into sql commands?
How can I manipulate expressions to help automate the creation of SQL commands like Linq to SQL? So: using Entityframework I can make queries such as: var livros = contexto.Livros .Where(livro =>…
-
2
votes1
answer78
viewsSearch information in more than one table
In my project I currently have 3 tables: Students, Occurrences and Users. In them I have the views and the controllers. So far, so good. My relationships are: Allunos&occurrences(1,N) /…
-
2
votes3
answers842
viewsCheck two or more occurrences of a listed element (lambda/Linq)
I have the following list<t> listCard; within it I have the following values: [0]:7720890002560 [1]:7720890002560 [2]:7777777002560 [3]:7720890002560 [4]:7720444402560 [5]:7720777002560…
-
2
votes2
answers79
viewsPHP - online lambda functions
Dear, I have a system where the user (with development permission) can program some online routines, to be executed within the system, without the need to create file and call via require / include.…
-
2
votes1
answer147
viewsMake calculation using LINQ
I am developing a program in c#. In it I have three tables: produto { string idProduto; string descricao; } entrada { string idProduto; int quant; } saida { string idProduto; int quant; } and I want…
-
2
votes1
answer468
viewsLeft Join in LINQ
I have the representation of 2 classes. first class: using System; using System.Runtime.Serialization; namespace WebService { [DataContract] public class PessoaDados { private Nullable<int>…
-
2
votes3
answers393
viewsSort children in consultation Linq
I’m having trouble making an ordination in a query where I have to sort the children by the ID, Follow the Source. public Grid GetByOrderGridData(long id) { var query = from c in…
c# asp.net-mvc entity-framework linq lambda-expressionsasked 7 years, 7 months ago Thiago Ubiratan 353 -
2
votes1
answer38
viewsHelp with Join in lambda query
I have the classes: profissional { int id; int idUnidade; string nome; } unidade { int id; string nome; } profissionalUnidade { string profissionalNome; string unidadeNome; } I’m making an…
-
2
votes1
answer55
viewsA problem to solve with English expressions
I did this, to return a list. It turns out to be an error, saying that there is no way to transform an anonymous expression into the past type (object). public List<Liberacao> PegaLiberacao()…
-
2
votes1
answer189
viewsHow can I make a MVC lambda filter
I’m making a simple filter, and show the data on the page. The code I’m using is this: mt.ModelItens = db.Forecast .Where(f => (f.CanalForecast.area == idArea && f.CanalForecast.despesa…
-
2
votes2
answers145
viewscreate_function can be a risk to my code?
PHP from the version 5.3 has implemented the resource called funções anônimas or Closure. Its use is this way: $sort = function ($a, $b) { return $a - $b; }; $array = [1, 3, 2]; usort($array,…
-
2
votes2
answers355
viewsLambda, Where com subconsulta
I need a consult like that on the lambda SELECT ClienteId --Aqui eu tenho varios campos do Cliente e estagioprocesso FROM Cliente WHERE ((SELECT TOP (1) EP FROM estagioprocesso WHERE…
-
2
votes1
answer594
viewsLinq + Lambda, sub-query, distinct and not in, how to improve this query
I had the following syntax in SQL SELECT tbl_boleto.int_IDC, tbl_Admin.int_STATUS, tbl_Admin.int_CONVENIO, tbl_Admin.int_PLANO, tbl_Admin.int_RESTRICAO, tbl_Admin.str_URL FROM tbl_boleto INNER JOIN…
c# asp.net-mvc entity-framework linq lambda-expressionsasked 8 years, 10 months ago Dorathoto 7,426 -
2
votes2
answers356
viewsMerge two items of an Ilist into one item by Id
In my class has: Id Venda Devolucao I have a IList of that class, and in that IList has [0] classe Id = 100, Venda = 230.00, Devolucao = 0; [1] classe Id = 100, Venda = 0, Devolucao = 50.00; [2]…
-
2
votes2
answers90
viewsWhy can normal functions not have "auto" arguments if "lambda Expressions" can in C++?
I realized that the "lambda Expressions" accept arguments of the type auto. For example: auto add = [](const auto& x, const auto& y) { return x + y; } So I tried normal functions, but it…
-
2
votes1
answer1039
viewsSort list by a string property with number
I have an object of the type Ata where I own the property NroAta which corresponds to the number of the minutes in question, but in grid when I sort by this number, it ends up putting the numbers in…
-
2
votes3
answers682
viewsHow to mount a lambda expression and pass it by parameter to a Generic function?
I need to pass two parameters to a generic function that returns database data and select only a few specific columns to display in one DataGridView. public List<TEntity>…
-
2
votes1
answer508
viewsPass lambda statement by parameter - C# - Entity
I have a method in which I need to pass only one select per parameter: public List<TEntity> GetAll(Expression<Func<TEntity, TEntity>> Select) { var query =…
-
2
votes2
answers1284
viewsForeach with lambda which returns the sum of iterated items
I’m trying to iterate on a List calling for produtos of objects called Produto, using the forEach, to obtain the sum of the values of these products using the lambda function of the forEach. But I…
-
2
votes2
answers111
viewsError When Generating Scaffold
I scaffolding generating the controller, and Index is showing an error in (f => f.Position) with this mistake: Cannot Convert lambda Expression to type 'string' because it is not a delegate the…
-
2
votes2
answers165
viewsHow can I get the highest value of a matrix with Lambda function in Python
In a list it is possible with the method "reduce" to achieve the highest value, but in a matrix I am not able to obtain the highest value of it: from functools import reduce matriz = [[4, 2, 56],…
-
2
votes3
answers86
viewsWhy do you print the variable type instead of the result?
See the method below: public void TesteLambda() { List<String> selecoes = new List<string>(); selecoes.Add("USA"); selecoes.Add("Brasil"); selecoes.Add("Itália"); selecoes.Add("França");…
-
2
votes2
answers122
viewsWhen consuming a service, error occurs in float or double fields in BD
When consuming the update service, this error occurs: The 'Datalib' Property on 'Release' could not be set to a 'System.Double' value. You must set this Property to a non-null value of type…
-
2
votes1
answer358
viewssum column lambda expression
I need to return the sum of the column value_business, I have the following expression dynamic contato = (from a in context.Negocio join cli in context.Pessoa on a.id_cliente equals cli.id_pessoa…
-
2
votes1
answer156
viewsConvert java lambda predicates
I am trying to perform a model transformation using java lambda. Below follows a block of code that exemplifies what I want to do: public String translatePrimitivePredicate(){…
-
2
votes1
answer46
viewsError when simulating distinc in query with Linq and lambda Expression
I have 2 tables in a Sqlserver bank. One tbState call and another tbCity. I am trying to return all states of the table tbState that have at least one city (tbCity) and with the properties…
-
2
votes1
answer792
viewsEntity lambda framework with include returns empty Collection
I have a select that returns chained data and plays it in a Viewmodel created for the simple reason that I cannot return all data from my table, as in the example: var data = _context.Forms…
-
2
votes0
answers82
viewsAssociate final variable to another reference in lambda expression
I was developing a code that uses lambda expressions, where variables outside the scope of the expression should be declared as final. Then the doubt arose: I can associate the variable declared as…
-
2
votes2
answers377
viewsTimout when searching between 2 date intervals
I have a query where I make a query between 2 date ranges. On those dates, I apply the DbFunctions.TruncateTime to filter searches only by dates, ignoring the time. Obs: are fields Datetime .Where(p…
-
2
votes1
answer166
viewsLambda function for Dict Dict - Python
I would like to know if there is the possibility of using the filter with a function lambda to select a conjunto de dados of a array de J SON in the Python. Example: I have the following JSON…
-
2
votes1
answer158
viewsHow to receive the result of an asynchronous function and move to Return?
I have the following code in nodejs in a lambda function in AWS that has been defined using serverless. The goal of this function is to read a URL that will return an XML, transform into JSON and…