2
I am using Entity Framework, I have a list of objects (data taken from the database) with data from Clients,
public virtual DbSet<clientes> clientes {get;set;}
public IEnumerable<clientes> FindAll()
{ db.Configuration.LazyLoadingEnabled = false;
return db.clientes.ToList();
}
and then on my form, I have a Grid
grid.datasource = clientes.ToList();
I’m calling the list right in the 'On Load' form, I’m only with 3 record in the database (SQLSERVER) and it’s taking more than 10 seconds to open the form..
In the class mapped the PK is this way :
[Key]
public int pk_cliente {get;set;}
I was wondering if the PK mapping is wrong and it’s getting lost somewhere.
Have you tried profiling your system before? I don’t think Entity Framework is the reason for the slowness, so I said.
– Leonel Sanches da Silva
Instead of having a Direct Reset on . Tolist() you create a variable and throw the tolist into it, at the moment of tolist it goes on the bench and back. The time to run this line will be the time spent with the database. Try this and speak the result.
– Ricardo
Managed to solve?
– Renan
@Renan yes, I got it! I posted the answer, thanks for asking.
– Leonardo