Esempio n. 1
0
    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;
    }
Esempio n. 2
0
    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));
    }
Esempio n. 3
0
    public void TestTranslate(Type type, bool canTranslate)
    {
        var canTranslateResult = ClrTypeToSqlTypeConverter.CanTranslateToSqlType(type);

        canTranslateResult.Should().Be(canTranslate);
        if (canTranslate)
        {
            Console.WriteLine(ClrTypeToSqlTypeConverter.Convert(type));
        }
    }