无法使用 MVC-Mini-Profiler 执行 Linq-To-Sql 存储过程

发布于 2024-11-26 05:26:39 字数 764 浏览 5 评论 0原文

我在 ASP.net 4.0 C# 环境中使用 MVC-Mini-Profiler 以及 MSSQL 和 Linq-to-SQL。我在将 L2S 与探查器一起使用时遇到问题。每当我返回 new DataClassesDataContext() 时,它都允许我从 L2S 存储过程获取数据。但是,如果尝试返回 Mvc-Mini-Profiler ProfilesDbConnection,我可以在构建后第一次从存储过程中获取数据,但此后每次都会返回零数据。当它使用 ProfiledDbConnection 返回 DataClassesDataContext 时,我仍然可以迭代 Db 表,但由于某种原因,存储过程不允许我发送/接收数据。关于为什么会这样的任何想法吗?

try
{
    var miniProfiler = MiniProfiler.Current;
    var connstring = new DataClassesDataContext().Connection.ConnectionString;
    SqlConnection connection = new SqlConnection(connstring);
    var profiledConnection = ProfiledDbConnection.Get(connection);
    var context = new DataClassesDataContext(profiledConnection);
    return context;
}
catch
{
    return new DataClassesDataContext();
}

I am using the MVC-Mini-Profiler in my ASP.net 4.0 C# environment along with MSSQL and Linq-to-SQL. I am having an issue with using L2S with the profiler. Whenever I return new DataClassesDataContext(), it allows me to get data from L2S stored procedures. But if try to return the Mvc-Mini-Profiler ProfilesDbConnection, I can get the data from the stored procedure on the first time after I build, but then ever time after that, zero data is returned. When it returns the DataClassesDataContext using ProfiledDbConnection, I can still iterate through the Db tables, but for some reason, the stored procedures do not allow me to send/receive data. Any ideas on why this might be?

try
{
    var miniProfiler = MiniProfiler.Current;
    var connstring = new DataClassesDataContext().Connection.ConnectionString;
    SqlConnection connection = new SqlConnection(connstring);
    var profiledConnection = ProfiledDbConnection.Get(connection);
    var context = new DataClassesDataContext(profiledConnection);
    return context;
}
catch
{
    return new DataClassesDataContext();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文