public static Collection <StoredProcedureParameterInfo> BuildStoredProcedureParameterInfo(object storedProcedure) { var parameters = new Collection <StoredProcedureParameterInfo>(); foreach (PropertyInfo propertyInfo in storedProcedure.GetType().GetProperties()) { var attribute = Attributes.GetAttribute <StoredProcedureParameterAttribute>(propertyInfo); if (attribute != null) { var parameterName = _helper.GetParameterName(propertyInfo); var isUserDefinedTableParameter = _helper.IsUserDefinedTableParameter(propertyInfo); var isMandatory = _helper.ParameterIsMandatory(attribute.Options); parameters.Add(new StoredProcedureParameterInfo { Name = parameterName, IsUserDefinedTable = isUserDefinedTableParameter, IsMandatory = isMandatory, SqlDataType = attribute.DataType, PropertyInfo = propertyInfo, Direction = attribute.Direction, Size = attribute.Size }); } } return(parameters); }
private static PropertyInfo GetMatchingProperty(object storedProcedure, SqlParameter parameter) { foreach (PropertyInfo propertyInfo in storedProcedure.GetType().GetProperties().Where(p => p.HasAttribute <StoredProcedureParameterAttribute>())) { var helper = new StoredProcedureParserHelper(); var name = helper.GetParameterName(propertyInfo); if (parameter.ParameterName.Substring(1) == name) { return(propertyInfo); } } return(null); }