private void InitialContext() { if (_tableObjs == null) { _tableObjs = new LibTableObj[] { } } ; Array.Clear(_tableObjs, 0, _tableObjs.Length); if (_ds.DefTables != null) { CreateTableSchemaHelp tableSchemaHelp = new CreateTableSchemaHelp(); foreach (LibDefineTable deftb in _ds.DefTables) { if (deftb == null || deftb.TableStruct == null) { continue; } foreach (LibDataTableStruct tbstruct in deftb.TableStruct) { Array.Resize(ref _tableObjs, _tableObjs.Length + 1); this._tableObjs[_tableObjs.Length - 1] = new LibTableObj(tableSchemaHelp.DoCreateTableShema(tbstruct, true, true)); this._tableObjs[_tableObjs.Length - 1].FromDSID = _ds.DSID; //this._tableObjs.Add(new LibTableObj(tableSchemaHelp.DoCreateTableShema(tbstruct))); } } } } #endregion }
public LibTableObj(string dsid, string tablenm) { LibDataSource _ds = SDPCRL.COM.ModelManager.ModelManager.GetDataSource(dsid); //101:数据原:{0} 不存在 if (_ds == null) { throw new LibExceptionBase(101, dsid); } //100:没有表结构 if (_ds.DefTables == null) { throw new LibExceptionBase(100); } this._dsid = dsid; foreach (LibDefineTable deftb in _ds.DefTables) { if (deftb.TableStruct == null) { continue; } foreach (LibDataTableStruct tb in deftb.TableStruct) { if (tb.Name.ToUpper() != tablenm.ToUpper()) { continue; } DataTable = new CreateTableSchemaHelp().DoCreateTableShema(tb); break; } } if (DataTable == null) { throw new LibExceptionBase(521); } GetColumns(); }