public virtual ValueGenerator Create(IProperty property, SqlServerSequenceValueGeneratorState generatorState, ISqlServerConnection connection)
        {
            Check.NotNull(property, nameof(property));
            Check.NotNull(generatorState, nameof(generatorState));
            Check.NotNull(connection, nameof(connection));

            if (property.ClrType.UnwrapNullableType() == typeof(long))
            {
                return new SqlServerSequenceValueGenerator<long>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(int))
            {
                return new SqlServerSequenceValueGenerator<int>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(short))
            {
                return new SqlServerSequenceValueGenerator<short>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(byte))
            {
                return new SqlServerSequenceValueGenerator<byte>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(char))
            {
                return new SqlServerSequenceValueGenerator<char>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(ulong))
            {
                return new SqlServerSequenceValueGenerator<ulong>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(uint))
            {
                return new SqlServerSequenceValueGenerator<uint>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(ushort))
            {
                return new SqlServerSequenceValueGenerator<ushort>(_executor, _sqlGenerator, generatorState, connection);
            }

            if (property.ClrType.UnwrapNullableType() == typeof(sbyte))
            {
                return new SqlServerSequenceValueGenerator<sbyte>(_executor, _sqlGenerator, generatorState, connection);
            }

            throw new ArgumentException(Internal.Strings.InvalidValueGeneratorFactoryProperty(
                nameof(SqlServerSequenceValueGeneratorFactory), property.Name, property.DeclaringEntityType.DisplayName()));
        }
        public virtual ValueGenerator Create(IProperty property, SqlServerSequenceValueGeneratorState generatorState, ISqlServerConnection connection)
        {
            Check.NotNull(property, nameof(property));
            Check.NotNull(generatorState, nameof(generatorState));
            Check.NotNull(connection, nameof(connection));

            if (property.ClrType.UnwrapNullableType() == typeof(long))
            {
                return(new SqlServerSequenceValueGenerator <long>(_executor, _sqlGenerator, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(int))
            {
                return(new SqlServerSequenceValueGenerator <int>(_executor, _sqlGenerator, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(short))
            {
                return(new SqlServerSequenceValueGenerator <short>(_executor, _sqlGenerator, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(byte))
            {
                return(new SqlServerSequenceValueGenerator <byte>(_executor, _sqlGenerator, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(ulong))
            {
                return(new SqlServerSequenceValueGenerator <ulong>(_executor, _sqlGenerator, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(uint))
            {
                return(new SqlServerSequenceValueGenerator <uint>(_executor, _sqlGenerator, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(ushort))
            {
                return(new SqlServerSequenceValueGenerator <ushort>(_executor, _sqlGenerator, generatorState, connection));
            }

            if (property.ClrType.UnwrapNullableType() == typeof(sbyte))
            {
                return(new SqlServerSequenceValueGenerator <sbyte>(_executor, _sqlGenerator, generatorState, connection));
            }

            throw new ArgumentException(Internal.Strings.InvalidValueGeneratorFactoryProperty(
                                            nameof(SqlServerSequenceValueGeneratorFactory), property.Name, property.EntityType.DisplayName()));
        }
コード例 #3
0
        public SqlServerSequenceValueGenerator(
            [NotNull] ISqlStatementExecutor executor,
            [NotNull] ISqlServerUpdateSqlGenerator sqlGenerator,
            [NotNull] SqlServerSequenceValueGeneratorState generatorState,
            [NotNull] ISqlServerConnection connection)
            : base(generatorState)
        {
            Check.NotNull(executor, nameof(executor));
            Check.NotNull(sqlGenerator, nameof(sqlGenerator));
            Check.NotNull(connection, nameof(connection));

            _sequence     = generatorState.Sequence;
            _executor     = executor;
            _sqlGenerator = sqlGenerator;
            _connection   = connection;
        }