title: Nested If Statement in Linq to SQL Query
body: <p>In SQL I would normally type this out, hard to read - yes, but it does work</p>
  
  <pre><code>(IIF(Table1.Field1 = 1,
      -- Field1 is True
      IIF(Table2.Field2= 1, (SUM(Table1.Field3+Table1.Field4)),(SUM(Table1.Field3+Table1.Field4)*-1))
   ,  -- Field1 is False
      IIF(Table2.Field2= 1, (SUM((Table1.Field3+Table1.Field4)*-1)), (SUM(Table1.Field3+Table1.Field4))))) AS Result
  </code></pre>
  
  <p>How would I translate this to a Linq query, I know I can do ternary, but is it possible to nest ternary?  </p>
  
  <p>Also my goals are to do this in one database call.  </p>