2011-08-09 104 views
0

我有一個由LINQ to SQL的IQueryable結果綁定的綁定源。將IQueryable轉換爲DataRowView

private void loadProducts(short _engineID) 
{  
    dbLinqDataContext db = new dbLinqDataContext();     
    var productQuery = from pe in db.productEngines 
         where pe.EngineID == _engineID 
         select new 
         { 
          ProductID = pe.ProductID, 
          ProductNumber = pe.product.ProductNumber, 
          Description = pe.product.ProductName, 
          Cost = String.Format("{0:C}", pe.product.StandardCost), 
          Price = String.Format("{0:C}", pe.product.ListPrice), 
          QOH = String.Format("{0:0.00}",pe.product.QOH), 
          Picture = pe.product.Picture, 
          Category =pe.product.category.Category1, 

          Engine=pe.engine.ModelSeriesYear, 
          Manufacturer=pe.engine.manufacturer.Manufacturer 
         }; 

productQueryBindingSource.DataSource = productQuery; }

然後我無法將我的bindingsource當前項目轉換爲DataViewRow。

DataRow currentRow = ((DataRowView)productQueryBindingSource.Current).Row; 

如何將我的匿名類型轉換爲DataViewRow類型?

回答

相關問題