8

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
DermFrench
  • 3,968
  • 13
  • 43
  • 70
  • How did you get this result, what query did you perform? – astaykov Apr 02 '13 at 12:02
  • @astaykov, logged in azure portal, Management Portal - SQL Database | Query Performance | Select particular query. Problem is I can't see what is passed into those parameters. – DermFrench Apr 02 '13 at 21:07
  • are you sure you don't see the parameters being passed? Looks like you are seeing the whole query which should contain the params in weird names like @p__linq__0 or so. – AD.Net Apr 07 '13 at 02:56

3 Answers3

1

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.

amhed
  • 3,649
  • 2
  • 31
  • 56
1

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.

Community
  • 1
  • 1
Fernando Correia
  • 21,803
  • 13
  • 83
  • 116
0

You can check query performance in administration portal. Here is link how to do it.

You can also connect to azure database through management studio. Here is a link how to do it. There you can check query plan and invoke manually your query.

jan salawa
  • 1,198
  • 1
  • 8
  • 25
  • you can't really SQL Server Profiler with SQL Azure. Plus everything you provided is diagnostics based on `history` and not `real time monitoring` like SQL Server Profiler does. And your link is not at all `you can connect to sql profiler`. It is just, how to diagnose and debug SQL Azure - very valuable indeed, but not using the `SQL Server Profiler` – astaykov Apr 02 '13 at 11:55