title: How can I convert this SQL query to a lambda expression
body: <pre><code>SELECT [t0].[Id], 
         [t0].[Challan_No], 
         [t0].[Type], 
         [t0].[Measurement], 
         [t0].[Update_By], 
         [t0].[Date], 
         [t1].[Id] AS [Id2], 
         [t1].[Challan_No] AS [Challan_No2], 
         [t1].[Own_Comany], 
         [t1].[Parti_Name], 
         [t1].[Update_By] AS [Update_By2], 
         [t1].[Date] AS [Date2], 
         [t1].[IsDelete], 
         [t1].[Isgenbill], 
         [t2].[Rate] AS [Rate1]
  FROM [dbo].[Challan_Total] AS [t0]
  INNER JOIN [dbo].[Challan] AS [t1] ON [t0].[Challan_No] = [t1].[Challan_No]
  INNER JOIN [dbo].[Rate] AS [t2] ON [t0].[Type] = [t2].[Meterial_type] 
                                  AND [t1].Own_Comany = [t2].Company_Id 
                                  AND [t1].Parti_Name=[t2].Parti_Id
  WHERE [t0].[Challan_No] = '2014CH 10002'
  </code></pre>
  
  <p>Here is what I came up with:</p>
  
  <pre><code>var getch = dm.Challan_Totals.Where(m =&gt; m.Challan_No == "")
                      .Join(dm.Challans,
                      c =&gt; c.Challan_No, d =&gt; d.Challan_No,
                      (c, d) =&gt; new { c, d }).Select(b =&gt; b)
                      .Join(dm.Rates, 
                      r =&gt; r.c.Type &amp;&amp; r.d.Own_Comany &amp;&amp; r.d.Parti_Name ,
                      s =&gt; s.Meterial_type &amp;&amp; s.Company_Id &amp;&amp; s.Parti_Id,
                     (r, s) =&gt; new { r, s.Rate1 });
  </code></pre>