예제 #1
0
        protected internal TableInfo Build(ISchemaProvider schemaProvider)
        {
            List <Column>      cols = new List <Column>();
            List <PostProcess> post = new List <PostProcess>();

            foreach (ColumnBuilder columnBuilder in _columns)
            {
                Column col = columnBuilder.Build(this, schemaProvider, post);

                if (col.IsPrimaryKey)
                {
                    _pkColumn = columnBuilder;
                }

                cols.Add(col);
            }

            schemaProvider.AddTable(_name, cols.ToArray());

            foreach (PostProcess process in post)
            {
                process.Action();
            }

            return(new TableInfo(_name, _pkColumn.Name, _pkColumn.ColumnType, _pkColumn.Size));
        }
예제 #2
0
        public IColumnBuilder AddPrimaryKey <T>(string columnName)
        {
            if (_pkColumn != null)
            {
                throw new InvalidOperationException("You can only add one primary key");
            }

            var builder = new PrimaryKeyBuilder(columnName, typeof(T));

            _columns.Add(builder);
            _pkColumn = builder;

            return(builder);
        }