private static void AddNecessaryAnnotations(NullableSqlType nullableSqlType, PropertyInfoWithAttributes propertyInfoWithAttributes) { foreach (var attribute in propertyInfoWithAttributes.Attributes) { DataAnnotationAttributeHandler.ProcessAttribute(nullableSqlType, attribute); } }
public static SqlColumnDeclaration Convert(PropertyInfoWithAttributes propertyInfoWithAttributes) { var nullableSqlType = ClrTypeToSqlTypeConverter.Convert(propertyInfoWithAttributes.PropertyInfo.PropertyType); var name = propertyInfoWithAttributes.PropertyInfo.Name; AddNecessaryAnnotations(nullableSqlType, propertyInfoWithAttributes); return(new SqlColumnDeclaration(name, nullableSqlType)); }
private static PropertyInfoWithAttributes CreatePropertyInfoWithAttributes(PropertyInfo propertyInfo) { var attributes = propertyInfo .GetCustomAttributes(false) .Where(att => att.GetType().Namespace?.Contains("System.ComponentModel.DataAnnotations") ?? false) .ToList(); var result = new PropertyInfoWithAttributes(propertyInfo, attributes); return(result); }