entity framework - How to convert EntityFramework generated SQL query to simple SQL Query -


i new in linq , in existing project linq has been used need write stored procedure 1 of linq query. have generated entityframework generated sql query below want write proper sql query in stored procedure.

select      [unionall1].[id] [c1],      [unionall1].[id1] [c2],      [unionall1].[name] [c3],      [unionall1].[ydstopin] [c4],      [unionall1].[windspeed] [c5],      [unionall1].[elevation] [c6],      [unionall1].[winddirection] [c7],      [unionall1].[startcoordinate] [c8],      [unionall1].[pincoordinate] [c9],      [unionall1].[targetcoordinate] [c10],      [unionall1].[linetype] [c11],      [unionall1].[published] [c12],      [unionall1].[unpublished] [c13],      [unionall1].[deleted] [c14],      [unionall1].[book_id] [c15],      [unionall1].[imagefile_id] [c16],      [unionall1].[situationcategory_id] [c17],      [unionall1].[c1] [c18],      [unionall1].[id2] [c19],      [unionall1].[situationid] [c20],      [unionall1].[handicapid] [c21],      [unionall1].[c2] [c22],      [unionall1].[c3] [c23],      [unionall1].[c4] [c24]      (select          case when ([extent2].[id] null) cast(null int) else 1 end [c1],          [extent1].[id] [id],          [extent1].[id] [id1],          [extent1].[name] [name],          [extent1].[ydstopin] [ydstopin],          [extent1].[windspeed] [windspeed],          [extent1].[elevation] [elevation],          [extent1].[winddirection] [winddirection],          [extent1].[startcoordinate] [startcoordinate],          [extent1].[pincoordinate] [pincoordinate],          [extent1].[targetcoordinate] [targetcoordinate],          [extent1].[linetype] [linetype],          [extent1].[published] [published],          [extent1].[unpublished] [unpublished],          [extent1].[deleted] [deleted],          [extent1].[book_id] [book_id],          [extent1].[imagefile_id] [imagefile_id],          [extent1].[situationcategory_id] [situationcategory_id],          [extent2].[id] [id2],          [extent2].[situationid] [situationid],          [extent2].[handicapid] [handicapid],          cast(null int) [c2],          cast(null int) [c3],          cast(null int) [c4]          [dbo].[situations] [extent1]         left outer join [dbo].[situationhandicaps] [extent2] on [extent1].[id] = [extent2].[situationid]         (0 = [extent1].[deleted]) , (1 = [extent1].[published]) , ([extent1].[situationcategory_id] = 1) , (( not exists (select              1 [c1]             ( select                  36 [c1]                  ( select 1 x ) [singlerowtable1]             )  [project1]             ( not exists (select                  1 [c1]                 [dbo].[situationattributes] [extent3]                 ([extent1].[id] = [extent3].[situationid]) , ([project1].[c1] = [extent3].[attributesid])             )) or (case when ( exists (select                  1 [c1]                 [dbo].[situationattributes] [extent4]                 ([extent1].[id] = [extent4].[situationid]) , ([project1].[c1] = [extent4].[attributesid])             )) cast(1 bit) else cast(0 bit) end null)         )) or ( exists (select              1 [c1]             ( select                  36 [c1]                  ( select 1 x ) [singlerowtable2]             )  [project5]              exists (select                  1 [c1]                 [dbo].[situationattributes] [extent5]                 ([extent1].[id] = [extent5].[situationid]) , ([project5].[c1] = [extent5].[attributesid])             )         ))) , (( not exists (select              1 [c1]             ( select                  1 [c1]                  ( select 1 x ) [singlerowtable3]             )  [project8]             ( not exists (select                  1 [c1]                 [dbo].[situationhandicaps] [extent6]                 ([extent1].[id] = [extent6].[situationid]) , ([project8].[c1] = [extent6].[handicapid])             )) or (case when ( exists (select                  1 [c1]                 [dbo].[situationhandicaps] [extent7]                 ([extent1].[id] = [extent7].[situationid]) , ([project8].[c1] = [extent7].[handicapid])             )) cast(1 bit) else cast(0 bit) end null)         )) or ( exists (select              1 [c1]             ( select                  1 [c1]                  ( select 1 x ) [singlerowtable4]             )  [project12]              exists (select                  1 [c1]                 [dbo].[situationhandicaps] [extent8]                 ([extent1].[id] = [extent8].[situationid]) , ([project12].[c1] = [extent8].[handicapid])             )         )))     union         select          2 [c1],          [extent9].[id] [id],          [extent9].[id] [id1],          [extent9].[name] [name],          [extent9].[ydstopin] [ydstopin],          [extent9].[windspeed] [windspeed],          [extent9].[elevation] [elevation],          [extent9].[winddirection] [winddirection],          [extent9].[startcoordinate] [startcoordinate],          [extent9].[pincoordinate] [pincoordinate],          [extent9].[targetcoordinate] [targetcoordinate],          [extent9].[linetype] [linetype],          [extent9].[published] [published],          [extent9].[unpublished] [unpublished],          [extent9].[deleted] [deleted],          [extent9].[book_id] [book_id],          [extent9].[imagefile_id] [imagefile_id],          [extent9].[situationcategory_id] [situationcategory_id],          cast(null int) [c2],          cast(null int) [c3],          cast(null int) [c4],          [extent10].[id] [id2],          [extent10].[situationid] [situationid],          [extent10].[attributesid] [attributesid]          [dbo].[situations] [extent9]         inner join [dbo].[situationattributes] [extent10] on [extent9].[id] = [extent10].[situationid]         (0 = [extent9].[deleted]) , (1 = [extent9].[published]) , ([extent9].[situationcategory_id] = 1) , (( not exists (select              1 [c1]             ( select                  36 [c1]                  ( select 1 x ) [singlerowtable5]             )  [project16]             ( not exists (select                  1 [c1]                 [dbo].[situationattributes] [extent11]                 ([extent9].[id] = [extent11].[situationid]) , ([project16].[c1] = [extent11].[attributesid])             )) or (case when ( exists (select                  1 [c1]                 [dbo].[situationattributes] [extent12]                 ([extent9].[id] = [extent12].[situationid]) , ([project16].[c1] = [extent12].[attributesid])             )) cast(1 bit) else cast(0 bit) end null)         )) or ( exists (select              1 [c1]             ( select                  36 [c1]                  ( select 1 x ) [singlerowtable6]             )  [project20]              exists (select                  1 [c1]                 [dbo].[situationattributes] [extent13]                 ([extent9].[id] = [extent13].[situationid]) , ([project20].[c1] = [extent13].[attributesid])             )         ))) , (( not exists (select              1 [c1]             ( select                  1 [c1]                  ( select 1 x ) [singlerowtable7]             )  [project23]             ( not exists (select                  1 [c1]                 [dbo].[situationhandicaps] [extent14]                 ([extent9].[id] = [extent14].[situationid]) , ([project23].[c1] = [extent14].[handicapid])             )) or (case when ( exists (select                  1 [c1]                 [dbo].[situationhandicaps] [extent15]                 ([extent9].[id] = [extent15].[situationid]) , ([project23].[c1] = [extent15].[handicapid])             )) cast(1 bit) else cast(0 bit) end null)         )) or ( exists (select              1 [c1]             ( select                  1 [c1]                  ( select 1 x ) [singlerowtable8]             )  [project27]              exists (select                  1 [c1]                 [dbo].[situationhandicaps] [extent16]                 ([extent9].[id] = [extent16].[situationid]) , ([project27].[c1] = [extent16].[handicapid])             )         )))) [unionall1]     order [unionall1].[id1] asc, [unionall1].[c1] asc 

please answer how convert above entityframework generated sql query code sql query


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -