/// <summary> /// Creates a new unique index. /// </summary> /// <typeparam name="TUniqueKey"> /// The type of the unique index key. /// </typeparam> /// <param name="indexFactory"> /// The index factory. /// </param> /// <param name="key"> /// The expression representing the definition of the index key. /// </param> /// <returns> /// The unique index. /// </returns> public IUniqueIndex <TEntity, TUniqueKey> CreateUniqueIndex <TUniqueKey>( IIndexFactory indexFactory, Expression <Func <TEntity, TUniqueKey> > keySelector) { var keyFactory = new ModularKeyInfoFactory(this.Database); var key = keyFactory.Create(keySelector); var index = indexFactory.CreateUniqueIndex(this, key); this.indexes.Add(index); this.OnIndexChanged(); return(index); }
/// <summary> /// Initializes a database table. /// </summary> /// <typeparam name="TEntity"> /// Specifies the type of the entities of the table. /// </typeparam> /// <typeparam name="TPrimaryKey"> /// Specifies the type of the primary key of the entities. /// </typeparam> /// <param name="primaryKey"> /// An expression that represents the primary key of the entities. /// </param> /// <param name="identitySpecification"> /// An IdentitySpecification to set an identity field. /// </param> /// <returns> /// An Table that represents the defined table object. /// </returns> public Table <TEntity, TPrimaryKey> Create <TEntity, TPrimaryKey>( Expression <Func <TEntity, TPrimaryKey> > primaryKey, IdentitySpecification <TEntity> identitySpecification) where TEntity : class { if (primaryKey == null) { throw new ArgumentNullException("primaryKey"); } IKeyInfoFactory keyInfoFactory = new ModularKeyInfoFactory(this.database); return(this.Create(keyInfoFactory.Create(primaryKey), identitySpecification)); }