Questions tagged as 'linq'

1
answer

How to use "Not Exists" in LINQ?

I'm trying to translate the query below into LINQ, but without success, can anyone help me? SELECT * FROM PESSOAL A WHERE NOT EXISTS ( SELECT Chapa FROM PRODUCAO B WHERE B.Chapa = A.Chapa AND B.Data='2014-09-02') AND A.Codsubord='CB...
asked by 10.09.2014 / 16:22
1
answer

Problem with Linq in Lambda: LINQ to Entities does not recognize ... get_Item (Int32). How to solve?

When trying to execute the loop for (when the query is executed) it is giving error in my lambda expression: var funcionarios = repository.Funcionarios .Include(x => x.Cargo) .Include(x => x.Bairro) .Include(x => x....
asked by 18.08.2014 / 23:48
1
answer

Problem returning Entity models: "The entity or complex type ... can not be constructed in a LINQ to Entities query"

I'm trying to return a list of objects generated by the DataBase First of the Entity Framework but I get this error:   The entity or complex type 'leaosites04Model.TB_LEMBRETES' can not be constructed in a LINQ to Entities query. I'm tryi...
asked by 03.07.2014 / 10:49
1
answer

Linq - Search for objects that have a pre-determined list

I have a many-to-many entity, many students for many subjects. And I need to get all the students who have all the materials I want. For example, subjects: Mathematics, Portuguese and Physics. I need to get only the students who have these th...
asked by 20.01.2016 / 17:36
1
answer

Converting a SQL from Sql Server to LINQ from C #

I have an sql that looks something like this: SELECT coluna1, coluna2, coluna3 FROM ( SELECT coluna1, coluna2, coluna3, ROW_NUMBER() OVER(ORDER BY coluna1, coluna3 desc) as row FROM tabela1 WHERE coluna4 in ('a', 'b', 'c...
asked by 18.12.2014 / 14:41
1
answer

How to convert lambda to expression trees format?

How to convert this lambda: Set.AsQueryable (). Where ( profile => Profile.CostCenters.Select (CostCentre => CostCentre.Id) .Any (Id => Ids.Contains (Id)) ) .ToList () Currently I've been able to do the following: profile.CostCenters.Sel...
asked by 11.06.2014 / 14:31
1
answer

How to group by 2 properties and add the values

I have no idea how to do this query in LINQ. How can I from sales list. Separate sales per hour, and then group the products and add up the quantities sold? public class Venda { public int Id {get;set;} public DateTime DataHora {get;se...
asked by 12.06.2014 / 17:45
1
answer

Dynamic Linq with C #

Inside the new in linq. I need to create the dynamic properties based on a data table how can I do this? var query = (from indicador in tableIndicado.AsEnumerable() group indicador by indicador.Field<string>("IND_CODUSU") into g...
asked by 18.11.2015 / 17:27
1
answer

How to insert values into a relational table when inserting a row and get this ID?

I am building a program to insert excel file data into a database. My database has this structure: Tables (and fields): Schedule ( PK ), StartTime, EndTime, DayWeek, RoomId ( FK ), ClassId < FK ), TeacherId ( FK )) Rooms (RoomId ( PK...
asked by 29.03.2015 / 04:20
1
answer

OR join using Linq

I have the following tables: Tabela1 Tabela2 Tabela3 Tabela4 +----+-----------+ +----+-----------+------+------+ +----+-----------+------+------+ +----+-...
asked by 14.10.2015 / 13:47