Ejemplo n.º 1
0
        private IEnumerable <CreateTableStatement> GetCreateTableStatements()
        {
            foreach (var entityMapping in _model.EntityMappings)
            {
                var tableStatementBuilder = new CreateTableStatementBuilder(_model, entityMapping);

                yield return(tableStatementBuilder.BuildStatement());
            }
        }
Ejemplo n.º 2
0
        public IRelationalCommand Build <TEntity>(SqlStatementKind statementKind, IEntityModel model, TEntity entity, IEntityMapping entityMapping)
        {
            switch (statementKind)
            {
            case SqlStatementKind.CreateTable:

                ISqlStatementBuilder <CreateTableStatement> statementBuilder = new CreateTableStatementBuilder(model, entityMapping);

                ISqlStatement statement = statementBuilder.BuildStatement();

                return(new RelationalCommand(statement.GetText(), null));

            case SqlStatementKind.Insert:

                ISqlStatementBuilder <InsertStatement> insertStatementBuilder = new InsertStatementBuilder(entity, entityMapping);
                InsertStatement insertStatement = insertStatementBuilder.BuildStatement();

                return(new RelationalCommand(insertStatement.GetText(), insertStatement.Parameters));

            case SqlStatementKind.Update:

                ISqlStatementBuilder <UpdateStatement> updateStatementBuilder = new UpdateStatementBuilder(entity, entityMapping);
                UpdateStatement updateStatement = updateStatementBuilder.BuildStatement();

                return(new RelationalCommand(updateStatement.GetText(), updateStatement.Parameters));

            case SqlStatementKind.Delete:

                ISqlStatementBuilder <DeleteStatement> deleteStatementBuilder = new DeleteStatementBuilder(entity, entityMapping);
                DeleteStatement deleteStatement = deleteStatementBuilder.BuildStatement();

                return(new RelationalCommand(deleteStatement.GetText(), deleteStatement.Parameters));

            default:

                throw new NotImplementedException();
            }
        }