Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Slowness to retrieve data
Message
From
06/12/2022 08:44:45
 
 
To
All
General information
Forum:
C#
Category:
Entity Framework
Title:
Slowness to retrieve data
Miscellaneous
Thread ID:
01685440
Message ID:
01685440
Views:
46
Hi
I am facing slowness issue when retrieve data via entityframework 6.
It query a table, with return 20 records only. The SQL statement is fast, completed within sec

However, when I use EF code as below, it takes 11-15 secs.
public class EmployeesDTO
    {
        public EmployeesDTO() { }
        public string employeeNo { get; set; }
    }

DbContext dbCtx = new DbContext("connectionstring");
SqlParameter para = new SqlParameter("@yearFor", SqlDbType.Char, 4);
string = "select ....";
para.Value = eaReportConfig.yearFor;
IList<EmployeesDTO> empList = dbCtx.Database.SqlQuery<EmployeesDTO>(sql, para).ToList(); // slowness

//Or

DbRawSqlQuery<EmployeesDTO> empList = dbCtx.Database.SqlQuery<EmployeesDTO>(sql, para);
foreach(EmployeesDTO emp in empList) // slowness
{
}
EmployeesDTO
Any idea? If I use normal ADO.NET code, it is fast.
I am not the most powerful man in this world.
I am not the worst man in this world either.
I just as same as all of you.
I still need to learn from my mistakes...
Next
Reply
Map
View

Click here to load this message in the networking platform