0 Replies - 8636 Views - Last Post: 05 February 2013 - 08:01 AM

#1 Xna4life  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 21-February 12

LINQ instead of insertOnSubmit()

Posted 05 February 2013 - 08:01 AM

So I was using an excel reader to read in a spreadhsheet. Compare the values on the SS to values I have in the DB. If they are different then update...so shorthand...
   ClarkeDBDataContext context = new ClarkeDBDataContext();
   Item_SubContractor updateItemSubContractor = new Item_SubContractor();  
   updateItemSubContractor.Item_id = tempBoqId;
   updateItemSubContractor.SubContract_id = subContractorId;

   //code to access rows and columns in spreadsheet

   Item_SubContractor Item_SC = (from Isc in db.Item_SubContractors
   where Isc.SubContract_id == subContractorId
   && Isc.Item_id == tempBoqId
   select Isc).ToList().FirstOrDefault();

  editPriceForSubcontractors = Convert.ToDecimal(r.ItemArray[4]);

  if (!(Item_SC.Price_Per_Unit == editPriceForSubcontractors))
   {
       Item_SC.Price_Per_Unit = editPriceForSubcontractors;
   }                                    
} 

//then at the bottom try and update changes I was using insert on submit but I think I have to use get?? Not sure, any ideas?
context.BOQ_SubContractors.Insertonsubmit(newBoqSubContractor);
  context.SubmitChanges();
  UpdatePage();



Is This A Good Question/Topic? 0
  • +

Page 1 of 1