private void AssignOutputValuesToInstance(CommandMapping cmdMap, SqlCommand currentCmd, ref PersistableObject persistObject) { SqlParameter curParam; ParameterDirection parameterDirection; foreach (CommandParameter cmdParameter in cmdMap.Parameters) { parameterDirection = cmdParameter.RealParameterDirection; if (parameterDirection == ParameterDirection.Output) { curParam = currentCmd.Parameters[cmdParameter.ParameterName]; if (curParam.Value != DBNull.Value) { PropertyInfo propertyInfo = persistObject.GetType().GetProperty(cmdParameter.ClassMember); if (propertyInfo == null) { throw new PropertyNotFoundException(cmdParameter.ClassMember); } propertyInfo.SetValue(persistObject, curParam.Value, null); } } } }
private void AssignValuesToParameters(CommandMapping cmdMap, ref SqlCommand currentCmd, PersistableObject persistObject) { ParameterDirection parameterDirection; foreach (CommandParameter cmdParameter in cmdMap.Parameters) { parameterDirection = cmdParameter.RealParameterDirection; if (parameterDirection == ParameterDirection.Input) { PropertyInfo propertyInfo = persistObject.GetType().GetProperty(cmdParameter.ClassMember); if (propertyInfo == null) { throw new PropertyNotFoundException(cmdParameter.ClassMember); } object propertyValue = propertyInfo.GetValue(persistObject, null); currentCmd.Parameters[cmdParameter.ParameterName].Value = propertyValue; } } }