Esempio n. 1
0
        private static Column BuildColumn(Table table, IProperty property)
        {
            var column =
                new Column(property.ColumnName(), property.PropertyType, property.ColumnType())
            {
                IsNullable              = property.IsNullable,
                DefaultValue            = property.ColumnDefaultValue(),
                DefaultSql              = property.ColumnDefaultSql(),
                ValueGenerationStrategy = property.ValueGenerationOnSave,
                IsTimestamp             = property.PropertyType == typeof(byte[]) && property.IsConcurrencyToken
            };

            table.AddColumn(column);

            return(column);
        }
        public override IValueGeneratorFactory Select(IProperty property)
        {
            if (property.ValueGenerationOnAdd == ValueGenerationOnAdd.Client)
            {
                // If INTEGER PRIMARY KEY column...
                var keyProperties = property.EntityType.GetKey().Properties;
                if (keyProperties.Count == 1 &&
                    keyProperties[0] == property)
                {
                    // TODO: Consider using RelationalTypeMapper service
                    var integerClrType = SQLiteTypeMap.FromDeclaredType("INTEGER", SQLiteType.Integer).ClrType;
                    if (property.PropertyType == integerClrType ||
                        string.Equals(property.ColumnType(), "INTEGER", StringComparison.OrdinalIgnoreCase))
                    {
                        // NOTE: This assumes no WITHOUT ROWID tables
                        return(_tempFactory);
                    }
                }
            }

            return(base.Select(property));
        }
        public override IValueGeneratorFactory Select(IProperty property)
        {
            if (property.ValueGenerationOnAdd == ValueGenerationOnAdd.Client)
            {
                // If INTEGER PRIMARY KEY column...
                var keyProperties = property.EntityType.GetKey().Properties;
                if (keyProperties.Count == 1
                    && keyProperties[0] == property)
                {
                    // TODO: Consider using RelationalTypeMapper service
                    var integerClrType = SQLiteTypeMap.FromDeclaredType("INTEGER", SQLiteType.Integer).ClrType;
                    if (property.PropertyType == integerClrType
                        || string.Equals(property.ColumnType(), "INTEGER", StringComparison.OrdinalIgnoreCase))
                    {
                        // NOTE: This assumes no WITHOUT ROWID tables
                        return _tempFactory;
                    }
                }
            }

            return base.Select(property);
        }
Esempio n. 4
0
        private static Column BuildColumn(Table table, IProperty property)
        {
            var column =
                new Column(property.ColumnName(), property.PropertyType, property.ColumnType())
                    {
                        IsNullable = property.IsNullable,
                        DefaultValue = property.ColumnDefaultValue(),
                        DefaultSql = property.ColumnDefaultSql(),
                        ValueGenerationStrategy = property.ValueGenerationOnSave,
                        IsTimestamp = property.PropertyType == typeof(byte[]) && property.IsConcurrencyToken
                    };

            table.AddColumn(column);

            return column;
        }