Пример #1
0
        private static TableHiLoGenerator CreateTableHiLoGenerator(TableIdGeneratorParams parameters)
        {
            var generator = new TableHiLoGenerator();

            Configure(parameters, generator);
            return(generator);
        }
Пример #2
0
        private static Int32MinimalGapTableIdGenerator CreateMinimalGapTableIdGenerator(
            TableIdGeneratorParams parameters)
        {
            var generator = new Int32MinimalGapTableIdGenerator();

            Configure(parameters, generator);
            return(generator);
        }
Пример #3
0
        private static void Configure(TableIdGeneratorParams parameters, IConfigurable generator)
        {
            var parms = new Dictionary <string, string>
            {
                { TableGenerator.TableParamName, parameters.TableName },
                { TableGenerator.ColumnParamName, parameters.ColumnName },
                { TableHiLoGenerator.MaxLo, parameters.InMemoryIncrementSize.ToString() }
            };

            generator.Configure(parameters.ColumnType, parms, parameters.Dialect);
        }
Пример #4
0
        protected static void AddTableAndColumnName <T>(Expression <Func <T, object> > propertyAccessor,
                                                        string columnNameSuffix,
                                                        TableIdGeneratorParams result)
        {
            string columnName = "Next_" + ReflectionUtil.GetAccessor(propertyAccessor).Name;

            if (!String.IsNullOrEmpty(columnNameSuffix))
            {
                columnName += columnNameSuffix;
            }
            string tableName = "tbl" + typeof(T).Name + "_NextNumber";

            result.ColumnName = columnName;
            result.TableName  = tableName;
        }
Пример #5
0
        /// <summary>
        /// Derive the parameters for a table backed id generator from the <paramref name="propertyAccessor"/>
        /// supplied
        /// </summary>
        /// <remarks>
        /// <example>
        /// <code>
        /// var paramseter = TableIdGeneratorParams.For&lt;Customer>(x => x.Reference, IdGeneratorStrategy.MinimalGap);
        /// </code>
        /// would create the parameters for a table backed <see cref="IIdGenerator{T}"/> whose id's would be stored in a table
        /// column 'tblCustomer_NextNumber.Next_Reference'
        /// </example>
        /// </remarks>
        /// <typeparam name="T">The entity type that is the subject of the id's that are to be generated</typeparam>
        /// <param name="propertyAccessor">An expression that identifies the property on the subject which is to have id's generated</param>
        /// <param name="columnNameSuffix">An optional suffix for the final column name</param>
        /// <param name="strategy">The id generating strategy</param>
        /// <returns></returns>
        public static TableIdGeneratorParams For <T>(Expression <Func <T, object> > propertyAccessor,
                                                     string columnNameSuffix,
                                                     IdGeneratorStrategy strategy)
        {
            var tableStrategies = new[]
            {
                IdGeneratorStrategy.MinimalGap,
                IdGeneratorStrategy.TableHiLow
            };

            Check.Require(() => Demand.The.Param(() => strategy).IsOneOf(tableStrategies));
            var result = new TableIdGeneratorParams();

            AddTableAndColumnName(propertyAccessor, columnNameSuffix, result);
            return(result);
        }