Esempio n. 1
0
        public ColumnEntity Create(ISession session, CleanUp cleanUp, TableEntity table = null, string name = null, string datatype = null, string description = null)
        {
            table = table ?? (new TableEntityCreator()).Create(session, cleanUp);

            name = name ?? RandomTool.RandomString(20);
            datatype = datatype ?? RandomTool.RandomString(20);
            description = description ?? RandomTool.RandomString(20);

            var entityToSave = new ColumnEntity
                {
                    DataType = datatype,
                    Description = description,
                    Name = name,
                    ParentTable = table
                };

            using (var transaction = session.BeginTransaction())
            {
                session.Save(entityToSave);
                transaction.Commit();
                cleanUp.AddForDeletion(entityToSave);
            }

            return entityToSave;
        }
        public void TestInitialize()
        {
            using (var session = SessionHelper.CreateASession())
            {
                _parentTable = new TableEntityCreator().Create(session, CleanUp);

                var columnCreator = new ColumnEntityCreator();
                Enumerable.Range(0, ColumnCount).Select(x => columnCreator.Create(session, CleanUp, table: _parentTable)).ToList();
            }
        }
Esempio n. 3
0
        public TableEntity Create(ISession session, CleanUp cleanUp, string name = null, string database = null, string description = null, string schema = null)
        {
            name = name ?? RandomTool.RandomString(20);
            database = database ?? RandomTool.RandomString(20);
            description = description ?? RandomTool.RandomString(20);
            schema = schema ?? RandomTool.RandomString(20);

            var tableToSave = new TableEntity
                {
                    DatabaseName = database,
                    Description = description,
                    Name = name,
                    SchemaName = schema
                };

            using (var transaction = session.BeginTransaction())
            {
                session.Save(tableToSave);
                transaction.Commit();
                cleanUp.AddForDeletion(tableToSave);
            }

            return tableToSave;
        }