Пример #1
0
        public static IEnumerable <TableStructure> Convert <T>(this List <T> aColumns, bool doConvertType) where T : DBColumn, new()
        {
            Dictionary <String, TableStructure> _tablesDic = new Dictionary <string, TableStructure>();
            DBTypeConverter _c = BaseFactory.Instance.GetInstance <DBTypeConverter>();

            foreach (DBColumn _t in aColumns)
            {
                TableStructure _n;
                if (_tablesDic.TryGetValue(_t.TABLE_NAME, out _n))
                {
                }
                else
                {
                    _n           = new TableStructure();
                    _n.TableName = _t.TABLE_NAME;
                    _n.Columns   = new List <Column>();
                    _tablesDic.Add(_n.TableName, _n);
                }

                bool _isPrimary = _t.CONSTRAINT_TYPE != null;
                _n.Columns.Add(new Column
                {
                    IsPrimaryKey = _isPrimary,
                    Name         = _t.COLUMN_NAME,
                    Type         = (doConvertType) ? _c.ConvertType(_t.DATA_TYPE, _isPrimary) : _t.DATA_TYPE,
                    DefaultValue = (doConvertType) ? _c.GetDefaultValue(_t.DATA_TYPE) : null
                });
            }

            return(_tablesDic.Values.ToList());
        }