在遺留系統中,我照顧必須將相同的記錄添加到表中兩次。無法用LINQ將記錄兩次添加到SQL中
表中有一個隨每個新記錄遞增的標識。
如果我做了以下我得到的錯誤: 「不能添加已經存在的實體」
有沒有辦法添加一條記錄的兩倍,而無需創建另一個PricingSnapshot對象?
PricingSnapshot pricingSnapshot = new PricingSnapshot
{
InvoiceOrderLineId = invoiceOrderLineId,
GrossPaymentValue = grossTotal,
CreatedBy = "Pricing Engine",
CreatedDate = DateTime.Now
};
dBpostChanges.PricingSnapshots.InsertOnSubmit(pricingSnapshot);
dBpostChanges.SubmitChanges();
dBpostChanges.PricingSnapshots.InsertOnSubmit(pricingSnapshot);
dBpostChanges.SubmitChanges();
我想你表中的一列是唯一的。你能顯示你的表格模式嗎? – user213225 2009-12-01 17:01:54