private void EnsureDatabaseWasUpdated() { if (AffectedRows == 0 && ThrowWhenNoRecordIsUpdated) { var rowVersionParameter = Parameters.Where(p => p.Name == "rowVersion").SingleOrDefault(); if (rowVersionParameter != null && rowVersionParameter.Value == DBNull.Value) { throw new DbConcurrencyException(); } throw new DbNoUpdatedException(); } }
private void AfterExecuteCommand(DbCommand command, bool useReturnValue, DbParameter returnParameter) { CopyOutParametersValue(command); if (useReturnValue) { ReturnCode = returnParameter.Value != null ? (int)returnParameter.Value : 0; } if (OutputParameterMaps.Any()) { if (RecordInstance == null) { throw new InvalidOperationException("Entity cannot be null if output parameter maps are configured"); } var accessor = RecordInstance.GetTypeAccessor(); foreach (var outputParameterMap in OutputParameterMaps) { var parameter = Parameters.Where(p => p.Name == outputParameterMap.Name).SingleOrDefault(); if (parameter == null) { throw new InvalidOperationException($"Output parameter of name: {outputParameterMap.Name} was not found"); } if (!parameter.IsOutput && !parameter.IsInputOutput) { throw new InvalidOperationException($"Output parameter of name: {outputParameterMap.Name} is neither input nor input-output"); } var value = accessor.GetValue(RecordInstance, outputParameterMap.Property); accessor.SetValue(RecordInstance, outputParameterMap.Property, parameter.Value); } } _onAfterCommandExecuted?.Invoke(this); }