I'm using linq to Entity to query an azure database. I've logged into azure to view a query that is giving a particular problem. I want to actually view the parameters passed in, but all azure gives me is below. Is there any way to view the parameters after the query has already run (e.g. changing the code to log them is not an option at the moment).
When I log into azure go to Management Portal - SQL Database | Query Performance | Select particular query. I can see the following: Problem is I can't see what has been passed into the parameters e.g. @p_linq_19. I'm only seeing a parameter placeholder.
SELECT TOP (150)
[Project1].[AlertIdentifier] AS [AlertIdentifier]
FROM ( SELECT
[Extent1].[AlertIdentifier] AS [AlertIdentifier],
[Extent1].[TimeReceived] AS [TimeReceived]
FROM [dbo].[SecurityAlert] AS [Extent1]
WHERE (2 <> [Extent1].[AlertStatusID]) AND ((convert(datetime2, '0001-01-01 00:00:00.0000000', 121) = @p__linq__0) OR ([Extent1].[DateScanned] >= @p__linq__1)) AND ((N'' = @p__linq__2) OR ([Extent1].[BettingShopIdentifier] LIKE @p__linq__3 ESCAPE N'~')) AND ((convert(datetime2, '0001-01-01 00:00:00.0000000', 121) = @p__linq__4) OR ([Extent1].[DateScanned] <= @p__linq__5)) AND ((cast(0 as float(53)) = @p__linq__6) OR ( CAST( [Extent1].[SlipStake] AS float) >= @p__linq__7)) AND ((@p__linq__8 < 1) OR ([Extent1].[SlipStatusID] = @p__linq__9)) AND ((cast(0 as float(53)) = @p__linq__10) OR ( CAST( [Extent1].[SlipPayoutActual] AS float) >= @p__linq__11) OR ( CAST( [Extent1].[SlipPayoutCalculated] AS float) >= @p__linq__12) OR ( CAST( [Extent1].[SlipPotentialReturn] AS float) >= @p__linq__13)) AND ((N'' = @p__linq__14) OR ([Extent1].[AlertSummary] LIKE @p__linq__15 ESCAPE N'~')) AND ((N'' = @p__linq__16) OR ([Extent1].[StaffScannedByUsername] LIKE @p__linq__17 ESCAPE N'~') OR ([Extent1].[StaffPayoutUsername] LIKE @p__linq__18 ESCAPE N'~') OR ([Extent1].[StaffEditedByUsername] LIKE @p__linq__19 ESCAPE N'~'))
) AS [Project1]
ORDER BY [Project1].[TimeReceived] ASC
I would go for the miniprofiler option. You can download it here: http://miniprofiler.com/ and configure it to profile your SQL connections.
Of course you wouldn't turn this on for production. You can either have it on just for the debug/staging scenarios, or configure the profiler to only render when a specific admin user is logged in.
An effective way, although requiring some configuration work, is to set up tracing at the Entity Framework level. That way you can log all SQL statements that are executed at the application level.
I suggest using the Community Entity Framework Provider Wrappers, also available as a NuGet package.
It's from 2011 but you can find instructions on using it with more recent versions of Entity Framework in this answer and in this forum thread.
There is an original blog post from a previous version that explains how this wrapper works.
Another alternative is using the MiniProfiler, as suggested by amhed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With