0
我正在使用數據庫對象類InvceDtl的對象將多個記錄添加到發票詳細信息表。什麼是重用同一個對象的最佳方式?使用同一對象添加記錄的最佳方法LINQ C#
InvDtl oInvDtl = new InvDtl(); // for inserting product
InvDtl.InvNo = invNo;
oInvDtl.ProdCode = ProdCode;
oInvDtl.ProdName = ProdName;
oInvDtl.Qty=qty;
oInvDtl.UnitPrce = UnitPrce;
oInvDtl.ExtPrce=ExtPrce;
dbContext.AddObject(oInvDtl);
dbContext.SaveChanges();
dbContext.Detach(oInvDtl);// --> should we detach oInvDtl object to use it again?
oInvDtl = new InvDtl(); // for inserting medication
oInvDtl.InvNo =invNo;
oInvDtl.MedCode =MedCode
.......
.......