private static void CreateComboTableColumn(MDModel_QueryModel QueryModel, MDQuery_ResultTable _resultTable, DataTable _ret) { MDModel_Table _tableDefine = MC_QueryModel.GetTableDefine(QueryModel, _resultTable.TableName); foreach (MDQuery_TableColumn _rc in _resultTable.Columns) { string FieldName = _rc.TableName + "_" + _rc.ColumnName; DataColumn _dc = new DataColumn(FieldName); _dc.Caption = _rc.ColumnTitle; bool _isRefTable = (_rc.RefDMB == null || _rc.RefDMB == "") ? false : true; _dc.DataType = CreateTypeByMeta(_rc.ColumnDataType, _isRefTable); _ret.Columns.Add(_dc); } }
/// <summary> /// 将查询结果集中的表建立表关联 /// </summary> /// <param name="_qv"></param> /// <param name="_ds"></param> public static void CreateDataRelation(MDModel_QueryModel _qv, DataSet _ds) { DataTable _mtable = _ds.Tables[_qv.MainTable.TableName]; _mtable.CaseSensitive = true; CheckMainKey(_mtable, "mainid"); _mtable.Columns["mainid"].Unique = true; _mtable.PrimaryKey = new DataColumn[] { _mtable.Columns["mainid"] }; for (int i = 0; i < _ds.Tables.Count; i++) { DataTable _dt = _ds.Tables[i]; _dt.CaseSensitive = true; if (_dt.TableName != _qv.MainTable.TableName) { MDModel_Table _ctable = MC_QueryModel.GetTableDefine(_qv, _dt.TableName); if (_ctable != null) { string _rname = _ctable.TableDefine.DisplayTitle; _ds.Relations.Add(_rname, _mtable.Columns["mainid"], _dt.Columns["mainid"]); } } } }