我正在使用ASP.Net和EF5开发应用程序。我正在使用MySQL作为数据库。我有一个仪表板,其中包含2个图表和一张地图。还有一些倒计时。它还包含过滤的下拉标准。 页面加载需要4分钟。我使用过优化查询。 随着数据的增加,加载时间也会增加。我必须优化它。 查询工作正常但是foreach迭代花费了太多时间。
我有4个部门,每个部门子句在foreach循环中都有一些类别。
if (Department1 == "Motor Vehicle Registration")
{
UniqueNos.Add(item.Number);
if (string.IsNullOrEmpty(item.FeedbackCategory) != true)
{
if (item.FeedbackCategory == "Appreciation")
{
if (MVRNos.Contains(item.Number) != true)
{
a++;
AllCategories.Add(item.FeedbackCategory);
}
}
else if (item.FeedbackCategory == "Corruption - General (Relevant to the department)")
{
if (MVRNos.Contains(item.Number) != true)
{
b++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
else if (item.FeedbackCategory == "Corruption - Specific (Relevant to the department)")
{
if (MVRNos.Contains(item.Number) != true)
{
c++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
else if (item.FeedbackCategory == "Corruption in the other office")
{
if (MVRNos.Contains(item.Number) != true)
{
dd++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
else if (item.FeedbackCategory == "Delay - Document/File not received")
{
if (MVRNos.Contains(item.Number) != true)
{
e++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
else if (item.FeedbackCategory == "Delay - Number Plate Not Received")
{
if (MVRNos.Contains(item.Number) != true)
{
f++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
else if (item.FeedbackCategory == "Delay - Others")
{
if (MVRNos.Contains(item.Number) != true)
{
g++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Don't Know")
{
if (MVRNos.Contains(item.Number) != true)
{
h++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Further inquiry required")
{
if (MVRNos.Contains(item.Number) != true)
{
i++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Others")
{
if (MVRNos.Contains(item.Number) != true)
{
j++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Other complaints (relevant to the department)")
{
if (MVRNos.Contains(item.Number) != true)
{
k++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Complaints (relevant to the other department)")
{
if (MVRNos.Contains(item.Number) != true)
{
l++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Suggestion (Relevant to the department)")
{
if (MVRNos.Contains(item.Number) != true)
{
m++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Suggestion (Relevant to the other department)")
{
if (MVRNos.Contains(item.Number) != true)
{
n++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Treatment (Unfair) to Customers")
{
if (MVRNos.Contains(item.Number) != true)
{
o++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Wrong Person")
{
if (MVRNos.Contains(item.Number) != true)
{
p++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
if (item.FeedbackCategory == "Irrelevant")
{
if (MVRNos.Contains(item.Number) != true)
{
q++;
MVRNos.Add(item.Number);
AllCategories.Add(item.FeedbackCategory);
}
}
}
}