public void InsertOrUpdate(Dto dto) { var updatedOrSavedEntity = _locationStore.GetTable <Entity>().FirstOrDefault(x => x.Id.Equals(dto.Id)); if (updatedOrSavedEntity != null) { UpdateEntry(dto, updatedOrSavedEntity); } else { updatedOrSavedEntity = CreateEntry(dto); _locationStore.GetTable <Entity>().InsertOnSubmit(updatedOrSavedEntity); } dto.Id = updatedOrSavedEntity.Id; _locationStore.SubmitChanges(); }