title: How to select record from select new clause in linq
body: <p>I have the following code
  I am having 3 tables as Department, DepartmentTask and DepartmentPosition. Here are the tables :</p>
  
  <pre><code>public partial class Department()
  {
     public int DepartmentId { get; set; }
     public string DepartmentName { get; set; }
     public Nullable&lt;int&gt; ParentDepartmentId { get; set; }    
  }
  public partial class DepartmentPosition
  {
      public int PositionId { get; set; }
      public int DepartmentId { get; set; }
      public string PositiontName { get; set; }        
  }
  public partial class DepartmentTask
  {
      public int TaskId { get; set; }
      public int DepartmentId { get; set; }
      public string TaskName { get; set; }       
  }
  </code></pre>
  
  <p>So any department can be a parent to another department, Task and Position. So here I want to select all the records from the tables which are children of a particular Department based on DepartmentId.</p>
  
  <pre><code>var z = from n in dbbs.Department
          select new
          {
              deptcount = dbbs.Department.Count(p =&gt; p.ParentDepartmentId == id),
              poscount = dbbs.DepartmentPosition.Count(x =&gt; x.DepartmentId == id),
              taskcount = dbbs.DepartmentTask.Count(t =&gt; t.DepartmentId == id)
          };
  if(z.Count()&gt;0)
  { 
  //do something
  }
  else
  {
  
  }
  </code></pre>
  
  <p>and now if there are no record within tables still it is coming within if block. I want to know how to restrict if there are no records as per the query.</p>