System.Data.DataColumnCollection

// Copyright (C), 2014, CEU Co., Ltd.
// USR Changed by 2014-10-14T12:27:59 Fandy Xie 谢宇帆
// Version       : 1.0
// Description   : 将table/view的fields添加到.net dataColumnCollection
// Return        :
static System.Data.DataColumnCollection getTableColumnsCollection(
    System.Data.DataColumnCollection    _colCollection,
    tableId                             _tableId)
{
    DictTable       dicTable;
    DictField       dictField, dfArray;
    set             setLabel    = new set(types::String);
    map             mapField    = new map(types::Integer, types::String);
    mapEnumerator   me;

    fieldId         fieldId;
    int             a, fieldCnt,m;
    name            fieldName, fieldLabel;
    container       con, fieldCon;
    identifiername  extend;
    types           type;
    System.Type     netType;
    ;

    dicTable    = new DictTable(_tableId);
    fieldCnt    = dicTable.fieldCnt();

    if(dicTable.isMap())// || dicTable.isSystemTable() || dicTable.isView())
        return _colCollection;
    for(m = 1;m <= fieldCnt; m++)
    {
        dictField   = new DictField(dicTable.id(),dicTable.fieldCnt2Id(m));
        fieldId     = dictField.id();
        fieldName   = dictField.name(dbBackend::Sql);
        fieldLabel  = dictField.label();
        type        = dictField.baseType();
        if(dictField.isSystem() && fieldName != "DATAAREAID")
            continue;
        if (!fieldName)
            continue;
        if (type == types::Container)
            continue;
        if (fieldName like "del_*")
            continue;

        extend = global::extendedTypeId2name(dictField.typeId());
        if (dictField.arraySize() > 1) // 数组 Dimension
        {
            for(a = 1; a <= dictField.arraySize(); a++)
            {
                dfArray     = new dictField(dicTable.id(), fieldId2Ext(dictField.id(), a));
                fieldId     = dfArray.id();
                fieldName   = dfArray.name(dbBackend::Sql);
                fieldLabel  = dfArray.label();
                if (!fieldLabel)
                    fieldLabel = fieldName;

                if (setLabel.in(fieldLabel))
                    continue;
                setLabel.add(fieldLabel);
                mapField.insert(fieldId, fieldName);
                _colCollection.Add(fieldName);
            }
        }
        else
        {
            if (!fieldLabel)
                fieldLabel = fieldName;
            if (setLabel.in(fieldLabel))
                continue;
            setLabel.add(fieldLabel);
            mapField.insert(fieldId, fieldName);
            _colCollection.Add(fieldName);
            //_colCollection.Add(fieldName,
            netType = System.Type::GetType("System.Int32");//int
            //System.Int64;//int64;
            /*
            System.String;//str;
            System.Int64;//int64;
            System.Int64;//int64;
            System.Int64;//int64;*/
        }
    }
    /*
    me = mapField.getEnumerator();
    while (me.moveNext())
    {
        fieldId     = me.currentKey();
        fieldName   = me.currentValue();
        lastCol++;
    }
    */
    return _colCollection;
}


转载于:https://my.oschina.net/fandyx/blog/374816

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值