我有一个视图模型的强类型视图,并且由于我今天早上做了一些代码更新,因此开始运行得非常慢。我安装了Glimpse MVC,看看我是否可以更好地了解可能发生的事情。 Glimpse适用于除ViewModel页面之外的每个页面 - 选项卡消失而不输出任何信息。
My Glimpse日志文件说:
2012-06-22 13:50:29.5831|INFO|Glimpse.Core.Module|BeginRequest handling complete for requestId 64d0e726-a756-4c1a-a9c4-629231948aa2 (/SurveyResponse/Results)|
2012-06-22 13:50:29.5851|WARN|Glimpse.Mvc3.Plugin.Execution|get_Binders method of System.Web.Mvc.ControllerActionInvoker type is not proxyable.|
2012-06-22 13:50:29.5851|WARN|Glimpse.Mvc3.Plugin.Execution|set_Binders method of System.Web.Mvc.ControllerActionInvoker type is not proxyable.|
2012-06-22 13:50:29.5851|WARN|Glimpse.Mvc3.Plugin.Execution|GetType method of System.Web.Mvc.ControllerActionInvoker type is not proxyable.|
2012-06-22 13:50:29.6101|WARN|Glimpse.Mvc3.Plugin.Execution|MemberwiseClone method of System.Web.Mvc.ControllerActionInvoker type is not proxyable.|
2012-06-22 13:50:30.5192|INFO|Glimpse.Core.Module|PostRequestHandlerExecute handling complete for requestId 64d0e726-a756-4c1a-a9c4-629231948aa2 (/SurveyResponse/Results)|
2012-06-22 13:50:30.5212|INFO|Glimpse.Core.Module|PostReleaseRequestState handling complete for requestId 64d0e726-a756-4c1a-a9c4-629231948aa2 (/SurveyResponse/Results)|
2012-06-22 13:50:30.5462|WARN|Glimpse.Core.Plumbing.GlimpseSerializer|Serializer error|System.ObjectDisposedException--The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.-- at System.Data.Objects.ObjectContext.EnsureConnection()
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Data.Entity.Internal.Linq.InternalQuery`1.GetEnumerator()
at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Newtonsoft.Json.Serialization.JsonArrayContract.CreateWrapper(Object list)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContract collectionValueContract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.WriteMemberInfoProperty(JsonWriter writer, Object memberValue, JsonProperty property, JsonContract contract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContract collectionValueContract)
2012-06-22 13:50:30.5602|WARN|Glimpse.Core.Plumbing.GlimpseSerializer|Serializer error|System.ObjectDisposedException--The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.-- at System.Data.Objects.ObjectContext.EnsureConnection()
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Data.Entity.Internal.Linq.InternalQuery`1.GetEnumerator()
at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Newtonsoft.Json.Serialization.JsonArrayContract.CreateWrapper(Object list)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContract collectionValueContract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.WriteMemberInfoProperty(JsonWriter writer, Object memberValue, JsonProperty property, JsonContract contract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContract collectionValueContract)
2012-06-22 13:50:30.5602|INFO|Glimpse.Core.Module|Glimpse JSON payload created for requestId 64d0e726-a756-4c1a-a9c4-629231948aa2 (/SurveyResponse/Results)|
2012-06-22 13:50:30.5702|INFO|Glimpse.Core.Module|Glimpse output generated for requestId 64d0e726-a756-4c1a-a9c4-629231948aa2 (/SurveyResponse/Results)|
2012-06-22 13:50:30.5702|INFO|Glimpse.Core.Module|RequestId 64d0e726-a756-4c1a-a9c4-629231948aa2 (/SurveyResponse/Results) persisted|
2012-06-22 13:50:30.5702|INFO|Glimpse.Core.Module|EndRequest handling complete for requestId 64d0e726-a756-4c1a-a9c4-629231948aa2 (/SurveyResponse/Results)|
2012-06-22 13:50:30.6272|INFO|Glimpse.Core.Module|BeginRequest handling complete for requestId 44be221e-a7e2-4ac7-bd4c-29ae2b9ad12f (/Glimpse.axd)|
2012-06-22 13:50:30.6422|WARN|Glimpse.Core.Validator.GlimpseRequestValidator|Glimpse.Core.Validator.ContentTypeValidator invalided request (it will now be ignored) with id 44be221e-a7e2-4ac7-bd4c-29ae2b9ad12f (/Glimpse.axd)|
2012-06-22 13:50:30.6482|WARN|Glimpse.Core.Validator.GlimpseRequestValidator|Glimpse.Core.Validator.ContentTypeValidator invalided request (it will now be ignored) with id 44be221e-a7e2-4ac7-bd4c-29ae2b9ad12f (/Glimpse.axd)|
2012-06-22 13:50:30.6482|WARN|Glimpse.Core.Validator.GlimpseRequestValidator|Glimpse.Core.Validator.ContentTypeValidator invalided request (it will now be ignored) with id 44be221e-a7e2-4ac7-bd4c-29ae2b9ad12f (/Glimpse.axd)|
2012-06-22 13:50:30.6642|WARN|Glimpse.Core.Validator.GlimpseRequestValidator|Glimpse.Core.Validator.ContentTypeValidator invalided request (it will now be ignored) with id 44be221e-a7e2-4ac7-bd4c-29ae2b9ad12f (/Glimpse.axd)|
导致性能不佳的代码是通过查询在我的组中添加这些Select语句:
var data = from SurveyResponseModel in db.SurveyResponseModels
group SurveyResponseModel by SurveyResponseModel.MemberId into resultCount
select new ResultsViewModel()
{
MemberId = resultCount.Key,
PatientFollowUpResult = db.SurveyResponseModels.Count(r => r.PatientFollowUp),
ChangeCodingPracticeResult = db.SurveyResponseModels.Count(r => r.ChangeCodingPractice),
ChangesOthersResult = resultCount.Select(r => r.ChangesOthers),
YesBarriersOthersResult = resultCount.Select(r => r.YesBarriersOthers),
AddressBarriersOthersResult = resultCount.Select(r => r.AddressBarriersOthers),
TotalResponsesResult = db.SurveyResponseModels.Count(),
};
答案 0 :(得分:0)
我想说的是,Glimpse正在触发模型中属性的延迟加载。不幸的是,Glimpae目前不支持这种情况。要测试是否是这种情况,请尝试并禁用视图选项卡,看看是否有同样的问题。