Questions tagged as 'entity-framework'

2
answers

Are there any differences between First and Single? [duplicate]

Are there any differences between First and Single? Are the two queries returned the same? And what about performance between the two is the same? Which of the two expressions is best to use?     
asked by 12.11.2016 / 20:07
2
answers

The type must be a reference type in order to use it as parameter 'TEntity' in the generic type or method 'DbSetTEntity'

I'm trying to set up an enum in ENTITY FRAMEWORK. But I'm not having success. My Context looks like this: public class MoradaWebContext : DbContext { public DbSet<MeuEnum> Status { get; set; } } The Enum looks like this: public...
asked by 16.03.2017 / 20:20
1
answer

How to work with Database Views in ASP.NET MVC?

Views does not have a primary key then it generates the error:    Error: The number of primary key values passed must match number of   primary key values defined on the entity. How could you do to avoid this error? public ActionResul...
asked by 08.04.2015 / 03:41
2
answers

Prevent the user from voting on the same Post

I created a voting system, where users can give like / dislike in chapters of books posted on the site. Here is my action: public ActionResult Like(int id) { int iduser = Convert.ToInt32(Session["IDUsuario"]);...
asked by 06.11.2014 / 04:11
2
answers

No parameterless constructor defined for this object

I'm trying to create a parameterized constructor, as shown below: public class TestController : Controller { private readonly IAppService _servico; public DashboardController(IAppService servico) { _servico = servico;...
asked by 12.09.2018 / 15:53
1
answer

Use Existing Database with Entity Framework

I need help to find out if there is a way to use an existing database with Entity Framework without having to use Visual Studio import, and without using Database First because I do not want tie my code, because I think that way it gets harder...
asked by 07.10.2014 / 21:35
1
answer

Query too slow to export in excel

I have created a method to export some columns to xls and the process is very slow, it takes almost one minute to do the whole process. public void Download(string datainicio, string datafinal, int? searchContrato, string searchCliente, st...
asked by 21.03.2018 / 13:22
1
answer

Return data from 2 tables entity framework

I have the following table: Movement -movement -Indicator -ProductId When I select a particular customer I want to list all of the trades in which they are together with the product. how would I call this inside the controller? That's what...
asked by 07.02.2018 / 00:27
1
answer

Relationships with the Entity Framework?

Next, I'm modeling the domain class of a system and I'm having trouble understanding certain things of Entity Framework , so I hope you can help me by looking at what I'm following the idea of Code First : In a relationship of...
asked by 22.09.2017 / 19:47
2
answers

apply filter on return from a list

I'm doing an query where I have a array of situations ex: 1, 2, 3 in the query I have to filter for these situations, follow my code. var array = GetSituacoes(); var lista = bll.Query(p => p.Contrato.PessoaFisica.ID == SessionControl.Pess...
asked by 17.05.2017 / 16:34