Пример #1
0
        public Info Build(string name, IEnumerable<TSqlColumn> fieldColumns)
        {
            var tableName = new ObjectIdentifier(new string[] { "dwh", name + "Info" });
            var identity = new IdentityFactory().Build(name + "Info" + "Id");

            var info = new Info()
            {
                Name = tableName,
                Identity = identity,
                Fields = new List<TSqlColumn>(fieldColumns)
            };

            return info;
        }
Пример #2
0
        public Info Build(string schema, string name, string suffix, Tuple<string, string> key, IEnumerable<Tuple<string, string>> fields)
        {
            var tableName = new ObjectIdentifier(new string[] { schema, name + suffix });
            var identity = new IdentityFactory().Build(name + suffix + "Id");
            var fieldColumns = new List<TSqlColumn>();

            var sqlDataTypeFactory = new TSqlDataTypeFactory();
            var columnFactory = new ColumnFactory();

            TSqlDataType sqlDataType;
            TSqlColumn keyColumn = null;

            if (key!=null)
            {
                sqlDataType = sqlDataTypeFactory.Build(key.Item2);
                keyColumn = columnFactory.Build(key.Item1, sqlDataType);
            }

            foreach (var field in fields)
            {
                var fieldName = field.Item1;

                sqlDataType = sqlDataTypeFactory.Build(field.Item2);
                var column = columnFactory.Build(fieldName, sqlDataType);
                fieldColumns.Add(column);
            }

            var info = new Info()
            {
                Name = tableName,
                Identity = identity,
                Fields = fieldColumns
            };

            return info;
        }