title: Linq Sub Select Data Type
body: <p>Learning Linq is going to be the death of me, hahahaha.</p>
  
  <p>I have a large query to retrieve data for a report. I need to add a sub query to get related data into the result set. The data in the subquery is a float in the database. My error is "Cannot convert type 'System.Linq.IQueryable' to 'float'"  </p>
  
  <p>The query is:</p>
  
  <pre><code>var results = from d in db.Deliveries
  join j in db.Jobs on d.Job equals j.Job1
  join c in db.Customers on j.Customer equals c.Customer1
  join ml in db.Material_Locations on j.Part_Number equals ml.Material into t1
  from t2 in t1.DefaultIfEmpty()
  join uv in db.User_Values on j.User_Values equals uv.User_Values into t3
  from t4 in t3.DefaultIfEmpty()
  where d.Promised_Date &gt;= calFrom.SelectedDate &amp;&amp; d.Promised_Date &lt;= calTo.SelectedDate
  where d.Remaining_Quantity &gt; 0
  where (t2.Location_ID ?? "") != "MSSICONSMT"
  orderby d.Job, c.Name, d.Promised_Date
  select new
  {
        d.Promised_Date,
        d.Job,
        LocationID = t2.Location_ID ?? "",
        d.Shipped_Quantity,
        d.Remaining_Quantity,
        d.Promised_Quantity,
        j.Unit_Price,
        on_Hand_Qty = ((double?)t2.On_Hand_Qty) ?? 0.0,
        Part_Number = j.Part_Number ?? "",
        c.Name,
        c.Ship_Lead_Days,
        SafetyStk = t4.Decimal1 ?? 0.0,
        ShipDate = d.Promised_Date.AddDays(-1 * (c.Ship_Lead_Days ?? 0)),
        RemainValue = d.Remaining_Quantity * j.Unit_Price,
        Balance = d.Remaining_Quantity &gt; 0 ? d.Remaining_Quantity - (((double?)t2.On_Hand_Qty) ?? 0.0) : 0,
        Consignment = ((float)(from x in db.Material_Locations
                          join jx in db.Jobs on x.Material equals jx.Part_Number
                          where jx.Job1 == d.Job
                                  &amp;&amp; x.Location_ID == "MSSICONSMT"
                          select new {x.On_Hand_Qty}))
  };
  </code></pre>
  
  <p>The problem is the "Consignment" line in the select. How do I deal with the anonymous type and get to converted into a float?</p>
  
  <p>Thanks!</p>