Maz*_*aie 3 c# asp.net entity-framework
通过使用EF,C#和ASP.NET 4 Web应用程序,我使用以下代码从数据库中检索数据并填充GridView:
using (AshModel am = this.conn.GetContext())
{
IEnumerable<Article> articles =
(from a in am.Article.AsEnumerable()
where (a.CultureName == calture || a.CultureName == 0)
&& a.IsApproved == status
&& a.IsPublished == status
orderby a.AddedDate descending
select a);
IEnumerable<Profile> profiles = am.Profile.AsEnumerable()
.Where(t => articles.Any(a => a.ProfileId == t.ProfileID));
foreach (Article article in articles)
article.UserProfile = profiles
.Where(a => a.ProfileID == article.ProfileId)
.FirstOrDefault();
this.gvArticles.DataSource = articles.ToList();
this.gvArticles.DataBind();
}
Run Code Online (Sandbox Code Playgroud)
但它非常慢,响应大约需要2分钟,数据库中只有500条记录!我的错误是什么?我如何才能提高绩效?谢谢.
| 归档时间: |
|
| 查看次数: |
239 次 |
| 最近记录: |