コード例 #1
0
        public IntegerTypeConfiguration <S> Maps(Expression <Func <S, int> > memberSelector)
        {
            IntegerTypeConfiguration <S> Configuration = new IntegerTypeConfiguration <S>(memberSelector);

            AddMapping(Configuration);
            return(Configuration);
        }
コード例 #2
0
        override internal void Get(object fromInstance, IDataEntityAdapter toEntity)
        {
            if (OrdinalProvider == null)
            {
                Error.PrepareDidnotCalled();
            }

            S Instance = (S)fromInstance;

            for (int i = 0; i < Configurations.Count; i++)
            {
                PropertyConfiguration configuration = Configurations[i];

                int Ordinal = OrdinalProvider[configuration.PropertyName];
                if (configuration.DataType == typeof(bool))
                {
                    BoolTypeConfiguration <S> Configuration = configuration as BoolTypeConfiguration <S>;
                    toEntity.SetBool(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(bool?))
                {
                    BoolTypeNullableConfiguration <S> Configuration = configuration as BoolTypeNullableConfiguration <S>;
                    toEntity.SetBool(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(short))
                {
                    ShortTypeConfiguration <S> Configuration = configuration as ShortTypeConfiguration <S>;
                    toEntity.SetShort(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(short?))
                {
                    ShortTypeNullableConfiguration <S> Configuration = configuration as ShortTypeNullableConfiguration <S>;
                    toEntity.SetShort(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(int))
                {
                    IntegerTypeConfiguration <S> Configuration = configuration as IntegerTypeConfiguration <S>;
                    toEntity.SetInt(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(int?))
                {
                    IntegerTypeNullableConfiguration <S> Configuration = configuration as IntegerTypeNullableConfiguration <S>;
                    toEntity.SetInt(Ordinal, Configuration[Instance]);
                }
                if (configuration.DataType == typeof(long))
                {
                    LongTypeConfiguration <S> Configuration = configuration as LongTypeConfiguration <S>;
                    toEntity.SetLong(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(long?))
                {
                    LongTypeNullableConfiguration <S> Configuration = configuration as LongTypeNullableConfiguration <S>;
                    toEntity.SetLong(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(double))
                {
                    DoubleTypeConfiguration <S> Configuration = configuration as DoubleTypeConfiguration <S>;
                    toEntity.SetDouble(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(double?))
                {
                    DoubleTypeNullableConfiguration <S> Configuration = configuration as DoubleTypeNullableConfiguration <S>;
                    toEntity.SetDouble(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(decimal))
                {
                    DecimalTypeConfiguration <S> Configuration = configuration as DecimalTypeConfiguration <S>;
                    toEntity.SetDecimal(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(decimal?))
                {
                    DecimalTypeNullableConfiguration <S> Configuration = configuration as DecimalTypeNullableConfiguration <S>;
                    toEntity.SetDecimal(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(DateTime))
                {
                    DateTimeTypeConfiguration <S> Configuration = configuration as DateTimeTypeConfiguration <S>;
                    toEntity.SetDateTime(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(DateTime?))
                {
                    DateTimeTypeNullableConfiguration <S> Configuration = configuration as DateTimeTypeNullableConfiguration <S>;
                    toEntity.SetDateTime(Ordinal, Configuration[Instance]);
                }
                else if (configuration.DataType == typeof(string))
                {
                    StringTypeConfiguration <S> Configuration = configuration as StringTypeConfiguration <S>;
                    toEntity.SetString(Ordinal, Configuration[Instance]);
                }
            }
        }
コード例 #3
0
        override internal void Set(IDataEntityAdapter fromEntity, object toInstance)
        {
            if (OrdinalProvider == null)
            {
                Error.PrepareDidnotCalled();
            }

            S Instance = (S)toInstance;

            for (int i = 0; i < Configurations.Count; i++)
            {
                PropertyConfiguration configuration = Configurations[i];

                int Ordinal = OrdinalProvider[configuration.PropertyName];

                if (configuration.DataType == typeof(bool))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        Error.CannotSetNullToNotNullableBooleanProperty(configuration.PropertyName);
                    }
                    else
                    {
                        BoolTypeConfiguration <S> Configuration = configuration as BoolTypeConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetBool(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(bool?))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        BoolTypeNullableConfiguration <S> Configuration = configuration as BoolTypeNullableConfiguration <S>;
                        Configuration[Instance] = null;
                    }
                    else
                    {
                        BoolTypeNullableConfiguration <S> Configuration = configuration as BoolTypeNullableConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetBool(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(short))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        Error.CannotSetNullToNotNullableShortProperty(configuration.PropertyName);
                    }
                    else
                    {
                        ShortTypeConfiguration <S> Configuration = configuration as ShortTypeConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetShort(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(short?))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        ShortTypeNullableConfiguration <S> Configuration = configuration as ShortTypeNullableConfiguration <S>;
                        Configuration[Instance] = null;
                    }
                    else
                    {
                        ShortTypeNullableConfiguration <S> Configuration = configuration as ShortTypeNullableConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetShort(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(int))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        Error.CannotSetNullToNotNullableIntProperty(configuration.PropertyName);
                    }
                    else
                    {
                        IntegerTypeConfiguration <S> Configuration = configuration as IntegerTypeConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetInt(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(int?))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        IntegerTypeNullableConfiguration <S> Configuration = configuration as IntegerTypeNullableConfiguration <S>;
                        Configuration[Instance] = null;
                    }
                    else
                    {
                        IntegerTypeNullableConfiguration <S> Configuration = configuration as IntegerTypeNullableConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetInt(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(long))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        Error.CannotSetNullToNotNullableLongProperty(configuration.PropertyName);
                    }
                    else
                    {
                        LongTypeConfiguration <S> Configuration = configuration as LongTypeConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetLong(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(long?))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        LongTypeNullableConfiguration <S> Configuration = configuration as LongTypeNullableConfiguration <S>;
                        Configuration[Instance] = null;
                    }
                    else
                    {
                        LongTypeNullableConfiguration <S> Configuration = configuration as LongTypeNullableConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetLong(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(double))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        Error.CannotSetNullToNotNullableDoubleProperty(configuration.PropertyName);
                    }
                    else
                    {
                        DoubleTypeConfiguration <S> Configuration = configuration as DoubleTypeConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetDouble(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(double?))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        DoubleTypeNullableConfiguration <S> Configuration = configuration as DoubleTypeNullableConfiguration <S>;
                        Configuration[Instance] = null;
                    }
                    else
                    {
                        DoubleTypeNullableConfiguration <S> Configuration = configuration as DoubleTypeNullableConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetDouble(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(decimal))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        Error.CannotSetNullToNotNullableDecimalProperty(configuration.PropertyName);
                    }
                    else
                    {
                        DecimalTypeConfiguration <S> Configuration = configuration as DecimalTypeConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetDecimal(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(decimal?))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        DecimalTypeNullableConfiguration <S> Configuration = configuration as DecimalTypeNullableConfiguration <S>;
                        Configuration[Instance] = null;
                    }
                    else
                    {
                        DecimalTypeNullableConfiguration <S> Configuration = configuration as DecimalTypeNullableConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetDecimal(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(DateTime))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        Error.CannotSetNullToNotNullableDateTimeProperty(configuration.PropertyName);
                    }
                    else
                    {
                        DateTimeTypeConfiguration <S> Configuration = configuration as DateTimeTypeConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetDate(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(DateTime?))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        DateTimeTypeNullableConfiguration <S> Configuration = configuration as DateTimeTypeNullableConfiguration <S>;
                        Configuration[Instance] = null;
                    }
                    else
                    {
                        DateTimeTypeNullableConfiguration <S> Configuration = configuration as DateTimeTypeNullableConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetDate(Ordinal);
                    }
                }
                else if (configuration.DataType == typeof(string))
                {
                    if (fromEntity.IsDBNull(Ordinal))
                    {
                        StringTypeConfiguration <S> Configuration = configuration as StringTypeConfiguration <S>;
                        Configuration[Instance] = null;
                    }
                    else
                    {
                        StringTypeConfiguration <S> Configuration = configuration as StringTypeConfiguration <S>;
                        Configuration[Instance] = fromEntity.GetString(Ordinal);
                    }
                }
            }
        }