tags:

views:

138

answers:

1

Hi i want to know how to create nested subquery in linq to entities.

e.g. this is my sql subquery which i want to translate in linq.

SELECT   
  @planned = COUNT(ID)  
FROM  Task_Detail  
WHERE task_id IN  
  (  
    SELECT   
      task_id  
    FROM  Story_Task   
    WHERE is_testcase = 'true' AND  
      story_id IN  
      (  
       SELECT str_id FROM dbo.story   
       WHERE prjId = @pro_id AND   
         str_id IN   
         (  
          SELECT str_id FROM dbo.Sprint_StoryMapping WHERE sprint_id = @sprintid  
         ) AND is_testcase = 'true'  
      )  
  )  AND status = 1 AND  
  DATEPART(dd,workDate) = DATEPART(dd,@stdt)
+1  A: 

Gut feel is that if you just turn this into a single select with the tables joined together, the whole query is going to run a lot faster and be easier to work with. Especially since your after an aggregate result.

Swanny