public void OnChange(BRecord entity, UpdateOperations operation) { switch (operation) { case UpdateOperations.Add: case UpdateOperations.Change: entity.ChangedDate = DateTime.Now; break; } }
static void Main(string[] args) { var ctx = new ConcurrencyTestDataContext(); var entityA = new ARecord { Value = "[0] created payload" }; ctx.ARecords.Add(entityA); ctx.SaveChanges(); entityA.Value = string.Format("[1] updated payload at {0}", DateTime.Now); ctx.SaveChanges(); entityA.Value = string.Format("[2] updated payload at {0}", DateTime.Now); ctx.SaveChanges(); var entityB = new BRecord { Value = "[0] created payload" }; ctx.BRecords.Add(entityB); ctx.SaveChanges(); entityB.Value = string.Format("[1] updated payload at {0}", DateTime.Now); ctx.SaveChanges(); entityB.Value = string.Format("[2] updated payload at {0}", DateTime.Now); ctx.SaveChanges(); var entityC = new CRecord { Value = "[0] created payload" }; ctx.CRecords.Add(entityC); ctx.SaveChanges(); entityC.Value = string.Format("[1] updated payload at {0}", DateTime.Now); ctx.SaveChanges(); entityC.Value = string.Format("[2] updated payload at {0}", DateTime.Now); ctx.SaveChanges(); var newContext = new ConcurrencyTestDataContext(); entityC.Value = string.Format("[3] updated payload at {0} via new data context", DateTime.Now); newContext.Attach(entityC); newContext.SaveChanges(); }
public FrmOperationRecord(AdminMsg LoginMsg) { InitializeComponent(); BRecord = new BRecord(LoginMsg.SqlConn); TheUser = LoginMsg; }
private void OnDetach(BRecord entity) { }
public void Detach(BRecord entity) { BRecords.Detach(entity); }
private BRecord AttachWithRelations(BRecord entity, InsertMode insertMode = InsertMode.Attach, MergeOption mergeOption = MergeOption.AppendOnly, List <object> referenceTrackingList = null) { #region iteration tracking if (ReferenceEquals(null, referenceTrackingList)) { referenceTrackingList = new List <object>(); } if (referenceTrackingList.Contains(entity)) { return(_bRecords.GetExisting(entity)); } else { referenceTrackingList.Add(entity); } #endregion #region add/attach entity BRecord existingEntity = null; switch (insertMode) { case InsertMode.Add: existingEntity = _bRecords.Add(entity); break; case InsertMode.Attach: existingEntity = _bRecords.Attach(entity); break; default: throw new Exception(string.Format("Implementation Exception: missing action for {0}", insertMode)); } if (!ReferenceEquals(null, existingEntity) && ReferenceEquals(existingEntity, entity)) { return(existingEntity); } #endregion #region attach relations recursively #endregion #region refresh existing entity based on merge options if (!ReferenceEquals(null, existingEntity) && !ReferenceEquals(existingEntity, entity)) { if (BRecords.MergeOption == MergeOption.OverwriteChanges) { Invoke(delegate { existingEntity.Refresh(entity, trackChanges: false); existingEntity.AcceptChanges(); }); } else if (BRecords.MergeOption == MergeOption.PreserveChanges) { Invoke(delegate { existingEntity.Refresh(entity, trackChanges: false, preserveExistingChanges: true); }); } } #endregion return(existingEntity); }
public void AttachAsModified(BRecord entity, BRecord original) { BRecords.AttachAsModified(entity, original); }
public void Attach(BRecord entity) { BRecords.Attach(entity); }
public void Delete(BRecord entity) { BRecords.Delete(entity); }
public void Add(BRecord entity) { BRecords.Add(entity); }
public Point(BRecord brec) { Latitude = brec.Latitude; Longitude = brec.Longitude; Altitude = brec.GnssAltitude; }