Sto cercando di inserire i dati nel mio database che dispone di 2 tavoliImpossibile eseguire il cast oggetto di tipo 'System.Data.Linq.DataQuery`1 [System.Int32]' digitare 'System.IConvertible'
Prodotti
(ProductID): 1
(IDNumber): 200.900.110
(ProductName): Pepsi
Order
(OrderID): 1 (incremento automatico di 1)
(ProductID): 1
(Data): 1/1/2009
Il codice è questo:
var db = new ProductOrder();
var idNum = from p in db.Product
where p.IDNumber == 200900110
select p.ProductID;
var order = new Order();
order.productID = Convert.ToInt32(idNum);
order.Date = DateTime.Now;
db.Order.InsertOnSubmit(nTime);
db.SubmitChanges();
Dopo l'eseguo mi dà l'errore come questo:
Impossibile eseguire il cast oggetto di tipo 'System.Data.Linq.DataQuery `1 [System.Int32]' digitare 'System.IConvertible'
Spero che nessuno menti - Ho corretto il rientro per mostrare dove le affermazioni sono più chiare. –