title: Using if else statement in Linq Query
body: <p>I am using following linq query to work with XML file..</p>
  
  <pre><code>XElement rootElement = XElement.Load(@"test.xml"); 
  int StyCode; 
  var lv1s = from lv1 in rootElement.Descendants("Class") 
  where lv1.Attribute("Code").Value.Equals("002") 
  select new 
  { 
  Children = from ltd in lv1.Descendants("Subject") 
  where ltd.Attribute("Course").Value.Equals("Math") 
  select new 
  { 
  
  ****//In This below section need result on condition based... ****
  if(StyCode=0)  
  {
  Children1 = ltd.Attribute("AllTeachers").Value.Equals("Y") ? true : false
  }
  else
  {
  Children2 = ltd.Attribute("SpeciaGuest").Value.Equals("Y") ? true : ltd.Elements("Topic").Attributes("Code").Where(x =&gt; x.Value.Equals("1")).FirstOrDefault() != null ? true : false 
  }
  } 
  }; 
  </code></pre>
  
  <p>Below is my XML Structure..</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Document&gt;
    &lt;Class Code="001"&gt;
      &lt;Subject Course="Math" AllTeachers='N' SpeciaGuest='N'&gt;&lt;/Subject&gt;
      &lt;Subject Course="Engish" AllTeachers='Y' SpeciaGuest='Y'&gt;&lt;/Subject&gt;
      &lt;Subject Course="History" AllTeachers='Y' SpeciaGuest='Y'&gt;&lt;/Subject&gt;
    &lt;/Class&gt;
    &lt;Class Code="002"&gt;
      &lt;Subject Course="Math" AllTeachers='Y' SpeciaGuest='N'&gt;
        &lt;Topic Code="1"&gt;LAW1&lt;/Topic&gt;
        &lt;Topic Code="2"&gt;
          LAW2
        &lt;/Topic&gt;
        &lt;Topic Code="3"&gt;
          LAW3&lt;/Topic&gt;
        &lt;/Subject&gt;
      &lt;Subject Course="Engish" AllTeachers='Y' SpeciaGuest='Y'&gt;&lt;/Subject&gt;
      &lt;Subject Course="History" AllTeachers='Y' SpeciaGuest='Y'&gt;&lt;/Subject&gt;
    &lt;/Class&gt;
  &lt;/Document&gt;
  </code></pre>
  
  <p>Please let me know, how I can use condition to select multiple select result. Also let me know using resharper in this linq query will be fine?.</p>