public static bool ShouldTranslateClrPropertyToSqlColumn(PropertyInfo arg, IEnumerable <string> columnsToIgnore = null) { if (IsColumnIgnored(arg, columnsToIgnore)) { return(false); } if (IsPropertyDatabaseGenerated(arg)) { return(false); } return(ClrTypeToSqlTypeConverter.CanTranslateToSqlType(arg.PropertyType)); // var isString = argType == typeof(string); // if (isString) // return true; // // // var implementsEnumerable = argType // .GetInterfaces() // .Any(interfaceType => interfaceType.Name.ToLower().Equals("ienumerable")); // // var isDatabaseGenerated = arg // .CustomAttributes // .Any(a => a.AttributeType == typeof(DatabaseGeneratedAttribute)); // // var shouldSkip = implementsEnumerable || isDatabaseGenerated; // return !shouldSkip; }
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)); }
public void TestTranslate(Type type, bool canTranslate) { var canTranslateResult = ClrTypeToSqlTypeConverter.CanTranslateToSqlType(type); canTranslateResult.Should().Be(canTranslate); if (canTranslate) { Console.WriteLine(ClrTypeToSqlTypeConverter.Convert(type)); } }