Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 0.82 KB  |  hits: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. C# Linq to SQL:cannot add an entity that already exists
  2. private static void AddNewPriceSettings(PRICE_SETTING priceSettingsInfo)
  3. {
  4.    PRICE_SETTING priceSetting = new PRICE_SETTING();
  5.    priceSetting = priceSettingsInfo;          
  6.    DataContext.CommonUsers.PRICE_SETTINGs.InsertOnSubmit(priceSettingsInfo);          
  7.    DataContext.CommonUsers.SubmitChanges();
  8. }
  9.        
  10. private static void AddNewPriceSettings(PRICE_SETTING priceSettingsInfo)
  11. {
  12.    PRICE_SETTING priceSetting = new PRICE_SETTING();
  13.    //
  14.    priceSetting.Prop1 = priceSettingsInfo.Prop1;
  15.    priceSetting.Prop2 = priceSettingsInfo.Prop2;
  16.    priceSetting.Prop3 = priceSettingsInfo.Prop3;
  17.    // ...
  18.    DataContext.CommonUsers.PRICE_SETTINGs.InsertOnSubmit(priceSetting );          
  19.    DataContext.CommonUsers.SubmitChanges();
  20. }
  21.        
  22. cannot add an entity that already exists