private void AddDeleteStatements(IEntity entity, EntityInfo entityInfo)
        {
            foreach (var valueInfo in entityInfo.Values)
            {
                foreach (var value in entity.GetValues(valueInfo))
                {
                    var builder = new ComplexCommandBuilder();
                    var idParameter = value.Id.ToParameter();
                    builder.AddParameter(idParameter);
                    var whereClause = string.Format("{0}.{1} = {2}", valueInfo.Name, valueInfo.Identifer.Name, idParameter.Name);
                    var statement = new DeleteStatement(valueInfo.Name, whereClause);
                    builder.AddStatement(statement);
                    Add(builder);
                }
            }

            foreach (var childInfo in entityInfo.Children)
            {
                foreach (var child in entity.GetChildren(childInfo))
                {
                    var builder = new ComplexCommandBuilder();
                    var idParameter = child.Id.ToParameter();
                    builder.AddParameter(idParameter);
                    var whereClause = string.Format("{0}.{1} = {2}", childInfo.Name, childInfo.Identifier.Name, idParameter.Name);
                    var statement = new DeleteStatement(childInfo.Name, whereClause);
                    builder.AddStatement(statement);

                    AddDeleteStatements(child, childInfo);
                    Add(builder);
                }
            }
        }
 private void AddRootCommandBuilder(EntityInfo entityInfo)
 {
     var builder = new ComplexCommandBuilder();
     builder.AddStatement(new CreateTableStatement(entityInfo));
     
     Add(builder);
 }
 private void AddSearchIndices(IEnumerable<ISearch> searches)
 {
     foreach (var search in searches)
     {
         var builder = new ComplexCommandBuilder();
         //var tableName = new EntityInfo(search.BaseType).Name;
         //var indexName = string.Format("{0}_{1}", tableName, search.Name);
         //builder.AddStatement(new CreateIndexStatement(search.SourceName, search.Name, false, search.Columns));
         builder.AddStatement(new CreateIndexStatement(search));
         Add(builder);
     }
 }
 private void AddLookupIndices(IEnumerable<ILookup> lookups)
 {
     foreach (var lookup in lookups)
     {
         var builder = new ComplexCommandBuilder();
         //var tableName = new EntityInfo(lookup.BaseType).Name;
         //var indexName = string.Format("{0}_{1}", tableName, lookup.Name);
         //builder.AddStatement(new CreateIndexStatement(tableName, indexName, true, lookup.Columns));
         builder.AddStatement(new CreateIndexStatement(lookup));
         Add(builder);
     }
 }
        protected void AddEntityDeleteStatement(IChild child, EntityInfo childInfo)
        {
            var builder = new ComplexCommandBuilder();

            var idParameter = child.Id.ToParameter();
            builder.AddParameter(idParameter);
            var whereClause = string.Format("{0}.{1} = {2}", childInfo.Name, childInfo.Identifier.Name, idParameter.Name);
            var statement = new DeleteStatement(childInfo.Name, whereClause);

            builder.AddStatement(statement);
            Add(builder);

            AddDeleteStatements(child, childInfo);
        }
        private void AddCommandBuilders(EntityInfo entityInfo)
        {
            foreach (var valueInfo in entityInfo.Values)
            {
                var builder = new ComplexCommandBuilder();
                builder.AddStatement(new CreateTableStatement(valueInfo));

                Add(builder);
            }

            foreach (var childInfo in entityInfo.Children)
            {
                var builder = new ComplexCommandBuilder();
                builder.AddStatement(new CreateTableStatement(childInfo));

                Add(builder);

                AddCommandBuilders(childInfo);
            }
        }
        protected void AddValueDeleteStatement(IValue value, ValueInfo valueInfo)
        {
            var builder = new ComplexCommandBuilder();

            var idParameter = value.Id.ToParameter();
            builder.AddParameter(idParameter);
            var whereClause = string.Format("{0}.{1} = {2}", valueInfo.Name, valueInfo.Identifer.Name, idParameter.Name);
            var statement = new DeleteStatement(valueInfo.Name, whereClause);

            builder.AddStatement(statement);
            Add(builder);
        }