Capture Stored Procedure print output in .NET (Different model!)

后端 未结 4 1015
余生分开走
余生分开走 2021-01-04 21:06

Basically, this question with a difference...

Is it possible to capture print output from a TSQL stored procedure in .NET, using the Entity Framework?

The so

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-04 21:48

    Based on the answer from @samneric, but with some modifications for EF Core we used this to allow debugging of a wayward stored procedure;

        DbConnection connection = Database.GetDbConnection();
        var sqlConnection = connection as SqlConnection;
        sqlConnection.InfoMessage += (s, a) => System.Diagnostics.Debug.WriteLine(a.Message);
    

提交回复
热议问题