Questions tagged as 'linq'

2
answers

How to convert Float to String using LINQ to entity?

How to convert Float to String using LINQ to entity? I need to convert a field from my database that has the float type to the string type in my C # using LINQ. Try using Convert.ToString, ChaveArquivo = Convert.ToString(n.scanIma.I...
asked by 22.09.2016 / 15:20
2
answers

ToList () returning read-only

Follow the code below: using (var db = new Entities()) { var result = db .Tabela1 .Select(x => new { x.Coluna1, x.Coluna2 }) .ToList(); foreach (var item in result)...
asked by 30.10.2017 / 22:26
2
answers

How to do an if else on a select when creating an object?

I do not know if the title was good, but the question is: listaAgendaDetalhe = (from a in listaAgenda join p in listaProfissional on a.idProfissional equals p.id select new agen...
asked by 28.06.2017 / 14:53
2
answers

Random Query List Linq to Entity C # [duplicate]

I would like to get a list of 3 objects within a query Link. var listaPessoas = from i in this.Context.CreateObjectSet<listaPessoas>() select i; ... listaPessoas = listaPessoas .Where(x => x.Nome.Contains(filtro.Nome); ......
asked by 31.08.2017 / 15:28
2
answers

FirstOrDefault, SingleOrDefault, ElementAtOrDefault [duplicate]

What is the difference between elements FirstOrDefault and First , SingleOrDefault and Single or ElementAtOrDefault or ElementAt . When to use with and without Default ?     
asked by 19.09.2017 / 16:47
2
answers

Catch all the fields of a class using Lambda + Group By

I have a list: produtosCompletos = (from f in estoques join p in produtos on f.idProduto equals p.id join c in classes on f.idClasse equals c.id select new produtoCompleto()...
asked by 24.04.2017 / 03:51
3
answers

What are the advantages of working with Fluent Interface with LINQ?

What are the advantages of working with a fluent interface with LINQ? I have this code: Employees.cs namespace LinqConsulta { class Empregados : List<Empregado> { public Empregados Lista() { this.Add...
asked by 07.06.2016 / 19:29
2
answers

Select where in in LINQ

How to convert the code select down into LINQ? select * from producao where id not in (select idProducao from bpi)     
asked by 17.02.2017 / 14:45
2
answers

Is there a LINQ method that returns a default value of my choice?

Is there a LINQ method that returns a default value of my preference that fulfills the role of this method more efficiently? public static int? procurarIdPorCpf(string cpf) { using (Contexto context = new Contexto()) { if (cont...
asked by 17.07.2014 / 17:48
2
answers

Bring three possible results with Lambda

I need in a single expression to bring three possible results. If date is up to 15dd, it returns 1, if it is between 15 and 45 dd returns 2 and if it is greater than 45 it returns 3. This is my lambda and the corresponding date field. var resu...
asked by 05.05.2014 / 20:52