我是使用LiNQ的新手。我有以下代碼,用於查找發票對象上零件的訂單數量。查詢結果來自LiNQ查詢
var invoiceQty = from i in returnInvoices
where i.PartNo == returnPart.PartNo && i.InvoiceID == hiddenInvoiceId.Value
select i.OrderLineQty;
if (Convert.ToInt32(txtReturnProdQty.Text) > Convert.ToInt32(invoiceQty))
{
args.IsValid = false;
SourceValidate.ErrorMessage = "Returned qty cannot be greater than quantity available on the invoice.";
txtReturnProdQty.Focus();
return;
}
我不認爲我正確地獲得OrderLineQty
值if語句,因爲它會產生以下錯誤:
System.InvalidCastException: Unable to cast object of type 'WhereSelectListIterator`2[Invoice,System.Double]' to type 'System.IConvertible'.
誰能幫助我瞭解如何使用返回值在LiNQ查詢中?
LiNQ需要一段時間才能沉入水中!
[呈三角問題] [1] [1]:http://stackoverflow.com/questions/792412/unable-to-cast-object-of-type-system-data-linq-dataquery1system-int32-to-ty 可能是你獲得多重價值 – user1964763 2013-02-27 16:21:24