Click here to Skip to main content
14,124,474 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I have a SQL statement which is causing a lot of performance issues on a production server.

Can you please help me out with a way so that i can convert this sql statement to linq so that I can search the output linq to narrow down the issue. We are using entity framework in the code.


(@p__linq__0 nvarchar(4000),@p__linq__1 nvarchar(4000),@p__linq__2 bigint,@p__linq__3 int,@p__linq__4 nvarchar(4000),@p__linq__5 nvarchar(4000),@p__linq__6 nvarchar(4000),@p__linq__7 nvarchar(4000),@p__linq__8 nvarchar(4000),@p__linq__9 bigint,@p__linq__10 bigint,@p__linq__11 nvarchar(4000),@p__linq__12 nvarchar(4000),@p__linq__13 bigint)SELECT [Limit1].[c2]              AS [C1], 
       [Limit1].[memberid]        AS [MemberId], 
       [Limit1].[membercode]      AS [MemberCode], 
       [Limit1].[membername]      AS [MemberName], 
       [Limit1].[siteid]          AS [SiteId], 
       [Limit1].[sitecode]        AS [Sitecode], 
       [Limit1].[sitename]        AS [SiteName], 
       [Limit1].[regid]           AS [RegId], 
       [Limit1].[resourcename]    AS [ResourceName], 
       [Limit1].[resfriendlyname] AS [ResFriendlyName], 
       [Limit1].[c1]              AS [C2], 
       [Limit1].[regtype]         AS [RegType], 
       [Limit1].[c3]              AS [C3], 
       [Limit1].[c4]              AS [C4], 
       [Limit1].[c5]              AS [C5], 
       [Limit1].[c6]              AS [C6], 
       [Limit1].[c7]              AS [C7], 
       [Limit1].[c8]              AS [C8], 
       [Limit1].[c9]              AS [C9], 
       [Limit1].[c10]             AS [C10], 
       [Limit1].[c11]             AS [C11], 
       [Limit1].[c12]             AS [C12], 
       [Limit1].[c13]             AS [C13], 
       [Limit1].[c14]             AS [C14], 
       [Limit1].[c15]             AS [C15] 
FROM   ( 
                  SELECT TOP (1) 
                             [Filter1].[siteid]          AS [SiteId], 
                             [Filter1].[sitename]        AS [SiteName], 
                             [Filter1].[sitecode]        AS [Sitecode], 
                             [Filter1].[memberid1]       AS [MemberId], 
                             [Filter1].[membercode]      AS [MemberCode], 
                             [Filter1].[membername]      AS [MemberName], 
                             [Extent4].[regid]           AS [RegId], 
                             [Extent4].[resourcename]    AS [ResourceName], 
                             [Extent4].[regtype]         AS [RegType], 
                             [Extent4].[resfriendlyname] AS [ResFriendlyName], 
                             N'Resource'                 AS [C1], 
                             0                           AS [C2], 
                             CASE 
                                        WHEN ( 
                                                              0 = @p__linq__3) THEN N'New' 
                                        ELSE N'Close' 
                             END           AS [C3], 
                             @p__linq__4   AS [C4], 
                             @p__linq__5   AS [C5], 
                             @p__linq__6   AS [C6], 
                             @p__linq__7   AS [C7], 
                             @p__linq__8   AS [C8], 
                             Sysdatetime() AS [C9], 
                             Sysdatetime() AS [C10], 
                             @p__linq__9   AS [C11], 
                             @p__linq__10  AS [C12], 
                             @p__linq__11  AS [C13], 
                             @p__linq__12  AS [C14], 
                             @p__linq__13  AS [C15] 
                  FROM       ( 
                                        SELECT     [Extent2].[siteid]       AS [SiteId], 
                                                   [Extent2].[memberid]     AS [MemberId2], 
                                                   [Extent2].[sitename]     AS [SiteName], 
                                                   [Extent2].[sitecode]     AS [Sitecode], 
                                                   [Extent3].[memberid]     AS [MemberId1], 
                                                   [Extent3].[membercode]   AS [MemberCode], 
                                                   [Extent3].[membername]   AS [MemberName] 
                                        FROM       [dbo].[asm_site_mapping] AS [Extent1] 
                                        INNER JOIN [dbo].[mstsite]          AS [Extent2] 
                                        ON         [Extent1].[asm_siteid] = [Extent2].[siteid] 
                                        INNER JOIN [dbo].[mstmember] AS [Extent3] 
                                        ON         [Extent1].[asm_memberid] = [Extent3].[memberid] 
                                        WHERE      1 = [Extent2].[isenabled] ) AS [Filter1] 
                  INNER JOIN [dbo].[regmain]                                   AS [Extent4] 
                  ON         [Filter1].[siteid] = [Extent4].[siteid] 
                  WHERE      ( 
                                        [Extent4].[sitecode] = @p__linq__0) 
                  AND        ( 
                                        [Extent4].[guid] = @p__linq__1) 
                  AND        ( 
                                        [Filter1].[memberid2] = @p__linq__2) ) AS [Limit1]


What I have tried:

I did try to use http://www.sqltolinq.com/Download/linqer_4.6.0.0_trial.zip
Bu not able to figure out the solution
Posted
Updated 1-Jul-18 19:40pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You can try LinqPad[^].
   
v2
Comments
Krunal Rohit 2-Jul-18 0:23am
   
5!
KR
Maciej Los 2-Jul-18 2:59am
   
Thank you, Krunal.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190518.1 | Last Updated 2 Jul 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100