asp.net-mvc-3 – MVC-Mini-Profiler错误地显示重复的查询
发布时间:2020-12-16 04:09:44 所属栏目:asp.Net 来源:网络整理
导读:我一直在玩MVC-Mini-Profiler,发现它非常有用.但是,在我追踪的所有页面上,我都会收到重复查询的报告,如下所示. 但是,我已经在SQL Server Profiler中跟踪了查询,毫无疑问它只能访问DB一次. 我在这里错过了一个概念还是我设置错了?对于有类似问题的人,我一直
我一直在玩MVC-Mini-Profiler,发现它非常有用.但是,在我追踪的所有页面上,我都会收到重复查询的报告,如下所示.
但是,我已经在SQL Server Profiler中跟踪了查询,毫无疑问它只能访问DB一次. 我在这里错过了一个概念还是我设置错了?对于有类似问题的人,我一直在搜索高低,没有运气,所以我怀疑是否存在错误. http://localhost:27941/clubs T+175.2 ms Reader 13.6 ms utePageHierarchy Execute System.Collections.Generic.IEnumerable<T>.GetEnumerator GetResults Execute ExecuteStoreCommands SELECT [Extent1].[TeamId] AS [TeamId],[Extent1].[Title] AS [Title],[Extent1].[TitleShort] AS [TitleShort],[Extent1].[LogoImageId] AS [LogoImageId],[Extent1].[Slug] AS [Slug],(SELECT COUNT(1) AS [A1] FROM [dbo].[Athletes] AS [Extent2] WHERE [Extent1].[TeamId] = [Extent2].[TeamId]) AS [C1] FROM [dbo].[Teams] AS [Extent1] WHERE 352 = [Extent1].[CountryId] http://localhost:27941/clubs T+175.4 ms DUPLICATE Reader 13.4 ms utePageHierarchy Execute System.Collections.Generic.IEnumerable<T>.GetEnumerator GetResults Execute ExecuteStoreCommands SELECT [Extent1].[TeamId] AS [TeamId],(SELECT COUNT(1) AS [A1] FROM [dbo].[Athletes] AS [Extent2] WHERE [Extent1].[TeamId] = [Extent2].[TeamId]) AS [C1] FROM [dbo].[Teams] AS [Extent1] WHERE 352 = [Extent1].[CountryId 我使用EF4并实现了这样的上下文: public class BaseController : Controller { public ResultsDBEntities _db; public BaseController() { var rootconn = ProfiledDbConnection.Get(GetStoreConnection(ConfigurationManager.ConnectionStrings["ResultsDBEntities"].ConnectionString)); var conn = ProfiledDbConnection.Get(rootconn); _db = ObjectContextUtils.CreateObjectContext<ResultsDBEntities>(conn); } public static DbConnection GetStoreConnection<T>() where T : System.Data.Objects.ObjectContext { return GetStoreConnection("name=" + typeof(T).Name); } public static DbConnection GetStoreConnection(string entityConnectionString) { DbConnection storeConnection; // Let entity framework do the heavy-lifting to create the connection. using (var connection = new EntityConnection(entityConnectionString)) { // Steal the connection that EF created. storeConnection = connection.StoreConnection; // Make EF forget about the connection that we stole (HACK!) connection.GetType().GetField("_storeConnection",BindingFlags.NonPublic | BindingFlags.Instance).SetValue(connection,null); // Return our shiny,new connection. return storeConnection; } } } 解决方法
我向Mini Profiler团队报告了这个问题(http://code.google.com/p/mvc-mini-profiler/issues/detail?id=62u0026amp;can=1),他们今天发布了一个补丁解决问题.
我想这将包含在下一个版本中.希望有所帮助:) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- .net – log4net – FileAppender在文件开头写入新条目
- Hangfire在ASP.NET CORE中的简单实现
- ASP.NET 5 HTML5历史
- asp.net – Lucene.Net和孵化状态
- reactjs – 用于SPA的Identity Server 4社交登录
- asp.net – 如何从HttpResponseMessage获取对象?
- asp.net – WebForms:MasterPages中的动态(或绝对)脚本标记
- 在asp.net上单击按钮的空文本框的Javascript验证
- asp.net-mvc – ASP.NET MVC Json DateTime序列化转换为UTC
- asp.net-mvc – ActionLink无法在“if”块内渲染
推荐文章
站长推荐
- asp.net – 请求验证 – 在SiteCore中如何以及为
- asp.net – 如何处理@RenderBody()?
- asp.net-mvc-4 – 自定义错误在我的MVC 4应用程序
- 在WinForms中验证用户(与ASP.Net无关)
- asp.net-mvc – 使用web.config关闭MVC中的身份验
- .net – 解密字符串时偶尔出现错误数据错误:Sys
- asp.net-mvc – 我可以在实际项目中使用Telerik
- asp.net-mvc-4 – MVC 4创建slug类型url
- VS 2015 Update 2 – 调试时不存在变量,为什么?
- asp.net – 为自定义UserControl提供呈现HTML中的
热点阅读