Questions tagged as 'linq'

3
answers

Comparison of = e = with strings

I have a field in the database that is in the following format: YYYYMM Using procedure I can normally search these fields: WHERE I.DT_INCL >= @inicio AND I.DT_INCL <= @final When I try to pass the query to linq it returns the...
asked by 06.03.2014 / 13:42
1
answer

Random order with Entity Framework

I would like to translate the following SQL statement to a lambda expression: SELECT TOP 1 * FROM tbPessoa order by NEWID() What do I put in the OrderBy that will be accepted? var pessoa = contexto.tbPessoa.OrderBy(???).FirstOrDe...
asked by 04.01.2017 / 14:34
1
answer

LEFT JOIN using Linq

I have the following tables: Responsavel | Filho Id Nome | Id Nome ResponsavelId 1 Ana | 1 Aninha 1 2 Maria | 2 Ana Júlia 1 3...
asked by 04.08.2015 / 18:52
1
answer

How to do a Lambda sort with a List property?

I believe this has already been asked before. I researched but did not find it. I'm having trouble with this query, specifically on the ThenBy command that tries to sort the sub-list of objects. I know it's in it because when you comme...
asked by 21.10.2014 / 18:23
4
answers

How to avoid repetition in LINQ queries?

I have the following LINQ query that is in a method that returns all products: var query = from p in Produtos select new Produto { ProdutoId = p.ProdutoId, Descricao = p.Descricao, Preco = p.Preco, Estoq...
asked by 17.01.2016 / 16:04
1
answer

Simulate the same SQL in the Entity Framework with Linq and Lambda?

Having this data model I want to generate a SQL in the Entity Framework with < a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx"> Linq and
asked by 03.07.2014 / 17:41
1
answer

Two dependent combobox using linq to sql

How do I populate two combobox's with linq to sql where in a combobox for example I have countries and in another I have cities? How do they automatically change the values? I leave the image below as I filled out one, if there are any errors an...
asked by 06.05.2016 / 02:16
1
answer

How to simplify the code with ForEach's List?

How to use ForEach() of List in the implementation below using System.Collections.Generic; public class Program { public static void Main() { List<Pessoa> pessoas = new List<Pessoa>(); pess...
asked by 17.10.2015 / 01:01
4
answers

Problems initializing a type inside a query with LINQ

I'm going through the following problem, I am putting an API into a forum application and this API needs an endpoint to return a collection of Forum that have the% property of% null. Then I put the following endpoint : [AllowAnonymou...
asked by 06.01.2016 / 11:43
1
answer

What is the correct way to declare a method thread and prevent the same method from being used out of scope?

In my last questions I was creating some methods to automate some queries. It's cool, but now I need to control access to methods by specifying a sequence. When using the Select () method, I can not access it again. After the Where () metho...
asked by 14.11.2014 / 21:12