Dav*_*ave 4 asp.net-mvc linq-to-entities entity-framework
我刚刚升级到VS 2013并且还启动了一个新的MVC项目,在我本地PC上进行调试时,IIS面临着几分钟内99%的CPU使用率.(发布和调试模式都发生)我刚刚意识到问题与Linq Query返回的行数成正比.如果我使用Take(1)或Take(10)就可以了.如果我使用Take(100),则会出现问题.
这是我的actionresult(私人信息已更改):
public ActionResult Summary(string daystoshow, DateTime? day = null)
{
int daysToShow = daystoshow.ToSafeInt();
if (daysToShow < 1) daysToShow = 2;
if (day == null) day = Convert.ToDateTime("4/14/2014");
SummaryViewModel m = new SummaryViewModel();
string warnings = "";
var ef1 = new carshowEntities();
DateTime dayAtMidnight = Convert.ToDateTime(((DateTime)day).AddDays(daysToShow).ToShortDateString());
var diplayItems = (from x in ef1.islands
join y in ef1.cars on x.serid equals y.serid where x.dt==12
join z in ef1.ITEMS on y.serviceno equals z.ITEMNO
join x2 in ef1.islands on x.serid equals x2.serid where x2.dt==8
join i in ef1.INVOICES on x.carStyle equals i.carStyle where i.STATUS==8
where x.LiscenceDate > day && x.LiscenceDate < dayAtMidnight
orderby x.LiscenceDate, y.serviceno, x.serid
select new ReturnedItem()
{
CarOrderDate = (DateTime)x.LiscenceDate,
serial = x.serid,
ItemCode = y.serviceno,
Description = z.Color,
DateSold = (DateTime)x2.LiscenceDate,
ID = i.IX_ID
}).Take(100).ToList();
m.daystoshow = daysToShow;
m.day = day;
m.diplayItems = diplayItems;
m.warnings = warnings;
return View(m);
}
Run Code Online (Sandbox Code Playgroud)
我还没有找到任何描述这里确切情况的帖子.
1)当网站发布时,它可以很好地从服务器上运行.
2)在调试模式下运行MVC项目时CPU使用率高达99%.
3)如果我在本地发布,问题就不会发生.
4)在调试或发布模式下从VS运行时,IIS和IIS Express都会发生这种情况.
5)到目前为止,这个项目不会发生在其他网站上.
6)这是一个简单的项目,一个actionresult,一个页面有一个约200行的表,填充了Linq查询.
有没有办法让调试器至少告诉我它在做什么?
编辑:
经过进一步调查,我注意到如果我等待2分钟,CPU将从IIS返回,但那么Web浏览器(Firefox或Chrome)将占用99%的CPU再持续2分钟.
| 归档时间: |
|
| 查看次数: |
701 次 |
| 最近记录: |