Questions tagged as 'entity-framework'

2
answers

Data search with Entity Framework

I have a project in Asp.Net MVC where I need to work with a large volume of data. To get them from the Database (Microsoft SQL Server) using Entity Framework 4 I basically know three ways: 1st form: var resultado = from p in db.Pessoa...
asked by 17.02.2016 / 12:34
1
answer

Generic method in DbSet of DbContext with Entity Framework

I have an application in C# that uses Entity Framework . All my DbSet of DbContext , I extend them to have a default search for the grid, below method example. public static GridDTO GridPadrao(this DbSet<Cliente...
asked by 17.06.2016 / 13:31
1
answer

Linq groups and fetches the max id

Is there any way to optimize the code below so that you search for the forms that are at the maximum version according to IdCentroCusto ? In the code below I'm doing the grouping and getting the CM.Max(d => d.Versao) to fetch...
asked by 07.12.2015 / 18:52
2
answers

Problem with inheritance

I have a problem with a search in the bank, I will try to explain it in the best possible and clearest way. I have a Pessoa table and a Cliente table, the last one inherits from Pessoa , I also have a Unidade table a...
asked by 03.11.2016 / 13:11
2
answers

Filtering collection of children in Entity Framework with Lambda

I have a case where I need to bring all the items of the parent object where it has a certain condition, for example: ctx.Pai .Where(x=> x.Ativo == true) .Include(Filhos) .Where(TrazerApenasFilhosAtivos); I've tried using Any...
asked by 17.07.2015 / 13:06
2
answers

How to do the where ands of where dynamically with linq and Entity Framework?

How can I make ands dynamically in where using Linq and entityFramework? Thank you in advance for any help. return _dbContext.TbParceiro //Preciso fazer algo do tipo mas isso não funciona, não sei como posso fa...
asked by 12.12.2017 / 18:33
2
answers

EntityFramework, Migrations and MySql. Schema name being misinterpreted. How to solve?

I'm having a problem using migrations with MySql . When I try to create the first version with Migrations it is making the schema / bank name part of the table name: public partial class Initial : DbMigration { public override...
asked by 03.07.2015 / 00:38
1
answer

Self-relationship in EF6

I need to do a self-relationship in one of the entities, how do I reference the entity itself for both child records and the parent record? public class Comentario { public int IdComentario { get; set; } public int? IdComentarioPai { g...
asked by 10.04.2014 / 15:10
1
answer

Update many to many Entity Framework c #

I'm having trouble updating a record with entityframework, I'll tell you the whole structure below. In short, I have a register of artists, where these artists are related to categories. entities: Artist: one-to-one relationship with addre...
asked by 12.02.2016 / 20:02
2
answers

Error creating data with foreign key

Hello, I am not able to insert data into a table that has foreign key, follow my model: 2tables,DepartamentoandFuncionario,theemployeehastheforeignkeyIdDepartamento.AndImanagedthecontrollerseverythingright,Icanaddadepartmentwithoutproblems,b...
asked by 18.11.2015 / 19:40