Questions tagged as 'linq'

2
answers

How to do query containing MAX and COUNT via LINQ

I have the following model : public class Crm_Analise { [Key] public int id { get; set; } public string cod_item_CRM { get; set; } public string TAG { get; set; } public string data_creat { get; set; } public str...
asked by 14.07.2017 / 13:26
3
answers

Sort the children in query Linq

I'm having trouble in ordering a query where I have to sort the children by the ID, Follow Source. public Grid GetByOrderGridData(long id) { var query = from c in context.Set<Grid>() where c.Id == id o...
asked by 28.06.2017 / 14:48
1
answer

Sort list by string property with number

I have an object of type Ata where I have the property NroAta that corresponds to the number of the Minutes in question, but in the grid when I will sort by this number, it ends up putting the numbers in the wrong order. Ex.:...
asked by 09.09.2016 / 20:53
2
answers

Using Array.Foreach to modify the collection

I want to remove spaces from the beginning and end of the string ( Trim ) in all positions of the array , but none of the forms below worked. What am I doing wrong? var optionArray = new string[] { "in the jungle ", " the mighty jungle"...
asked by 26.07.2016 / 19:34
1
answer

What is the most efficient way to get an Entity property?

I'm using EF6 and would like to know how to get the best performance by redeeming a single property from a Entity . Assuming the following case:    Let's say I need to fetch all names from a 5000-line user table. User.c...
asked by 20.12.2018 / 19:18
2
answers

Merge two distinct lists using LINQ

I have two classes, Cliente and Endereco , where the client has 1 or more addresses, so it is a list of objects: class Cliente { public string Nome { get; set; } public string Cpf { get; set; } public List<Endereco&...
asked by 21.07.2015 / 17:34
1
answer

SumAsync return zero

I have a query in LINQ where I use SumAsync , however when my entity is empty I have the exception:    The cast to value type 'System.Decimal' failed because the   materialized value is null. Either the result type's generic para...
asked by 08.01.2018 / 14:53
1
answer

Error performing LINQ query with equals at where closure

When you run the query below: public ActionResult GridViewPartial() { if (Session["cod_cli"] != null) { int cod_cli = Convert.ToInt32(Session["cod_cli"]); //var model = db.DadosTecnicos;...
asked by 31.07.2017 / 14:02
1
answer

Make calculation using LINQ

I'm 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; } I want to create a class l...
asked by 29.04.2017 / 16:51
4
answers

Entity inner join in LINQ

I wanted to make an inner join so that I get a list with the names of Logins from the Integer List of UsuarioID of class LoginsAtivos . public class Login { public int ID { get; set; } [Required] public string N...
asked by 28.06.2016 / 18:07