Linq interaction
Linq objects refer to an internal object, they are not cloned
Currency oldCurrency = new Currency();
oldCurrency = (from c in lrc.Currencies where c.CurrencyID == id select c).Single();
System.Data.Linq.Binary tms = oldCurrency.Tms;
mCurrency = (from l in lrc.csTtaCurrency_U1(mCurrency.CurrencyID, mCurrency.Name, mCurrency.ShortName, oldCurrency.Tms) select l).Single();
This code leaves both oldCurrency and mCurrency with the old value.
To have them refer to the new value, lrc.Refresh is needed. In this case they will both refer to the new currency. To have oldCurrency refer to the old, and mCurrency to the new, you have to make a clone:
Currency oldCurrency = new Currency();
oldCurrency = (from c in lrc.Currencies where c.CurrencyID == id select c).Single();
oldCurrency = (Currency) oldCurrency.MemberwiseClone();
System.Data.Linq.Binary tms = oldCurrency.Tms;
mCurrency = (from l in lrc.csTtaCurrency_U1(mCurrency.CurrencyID, mCurrency.Name, mCurrency.ShortName, oldCurrency.Tms) select l).Single();
lrc.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, mCurrency);
Some references
http://stackoverflow.com/questions/5483672/how-does-the-linq-refreshmode-work
http://stackoverflow.com/questions/6254220/what-is-the-correct-usage-of-datacontext-refresh
page revision: 5, last edited: 11 Feb 2015 12:52