Questions tagged as 'linq'

1
answer

How do I get the sql that linq generates for the VS2013 debug

How do I get the sql that linq generates for the VS2013 debug? How do I do this? I did it and it did not work public static List<MontaArvoreAcao> CriarListaArvoreUn(string _uf, string _cidade, string _un) { Ruptura...
asked by 02.10.2014 / 18:18
1
answer

Convert SQL query to LINQ

What would be the converted SQL query for LINQ: "SELECT SUM(valor_negocio) valor_negocio, " + " MONTHNAME(STR_TO_DATE(MONTH(data_inicio), '%m')) mes," + " STATUS" + " FROM negocio" + " WHERE data_inicio BETWEE...
asked by 04.11.2017 / 20:26
1
answer

Could not create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context

I'm trying to make a query in LINQ, and are returning the following error message:    A constant value of type 'System.Object' could not be created. Only primitive types or enumeration types are supported in this context A structure is re...
asked by 02.03.2016 / 15:25
0
answers

Service returns cast error when consumed

I decided to make another post, since the subject is another, although in the original post, in the comments we get to touch on the subject, but without depth. I have this error:    System.InvalidOperationException: 'The specified cast from a...
asked by 25.08.2017 / 15:14
3
answers

Performance "where in foreach vs if"

Which of the cases would perform best? var chaves = new list<string>(); foreach(var item in lista) { if(!string.IsNullOrEmpty(item.Chave)) { chaves.Add(item.Chave); } } Or listaValida = lista.Where(x => !string.IsN...
asked by 13.04.2017 / 17:13
3
answers

How to create a custom list using data from four tables?

I have the following class: Nota { int id; int idFornecedor; int idProduto; int idClasse; } and I have the respective classes referring to the ids of the previous class: Fornecedor { int id; string descricao; } Pr...
asked by 11.04.2017 / 13:01
2
answers

Clause in with lambda

Is it possible to have an IN clause with lambda expression? Type: context.tabela.Where(a => a.meu_campo_id_tipo_inteiro....) let's say an in like this: (2,3,4,5) How do I put on the dots?     
asked by 02.06.2014 / 17:41
4
answers

OrderBy in T lists

I have a list list<Pessoas> : My class people: public class Pessoas { public String Nome { get; set; } public DateTime Nascimento { get; set; } } Theoretically, I could make a OrderBy like this: Pessoas.Order...
asked by 31.03.2015 / 19:13
3
answers

How do I use Skip and Take with the PagedList Helper

I would like to paginate, but using Skip and Take in my LINQ not to fetch all results. Currently my code looks like this: public ViewResult Index(int? page) { var grupos= from s in db.grupos...
asked by 20.08.2014 / 19:23
3
answers

How to filter an IEnumerable type list through another IEnumerable?

How to filter a list type IEnumerable<> by passing a parameter of type IEnumerable<> preferably via expression lambda or linq ? Based on the filter below, I expect this result: {MundoId = 0, Continente...
asked by 01.06.2017 / 13:28