/// <summary> /// Derive the parameters for a table backed id generator from the <paramref name="propertyAccessor"/> /// supplied /// </summary> /// <remarks> /// <example> /// <code> /// var paramseter = TableIdGeneratorParams.For<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); }
/// <summary> /// Derive the parameters for a table backed id generator from the <paramref name="propertyAccessor"/> /// supplied /// </summary> /// <remarks> /// <example> /// <code> /// var paramseter = TableIdGeneratorParams.For<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="strategy">The id generating strategy</param> /// <returns></returns> public static TableIdGeneratorParams For <T>(Expression <Func <T, object> > propertyAccessor, IdGeneratorStrategy strategy) { return(For(propertyAccessor, null, strategy)); }