public void UpdateIndices() { var metaCol = m_SourceTable.GetMetaData().GetColumnByIndex(m_columnIndex); var col = m_SourceTable.GetColumnByIndex(m_columnIndex); if (metaCol == null || col == null) { UnityEngine.Debug.LogError("No column index " + m_columnIndex + " on table '" + m_SourceTable.GetName() + "'"); indices = new long[0]; } var t = metaCol.Type; Matcher m; if (t == typeof(string)) { var ssm = new SubStringMatcher(); ssm.value = m_matchString; m = ssm; } else { m = ColumnCreator.CreateConstMatcher(t, m_matchString); if (m == null) { indices = new long[0]; return; } } var matchIndices = col.GetMatchIndex(m_Range, m); indices = matchIndices; }
public void RegisterMembers(DataTable table, ColumnCreator creator, string schema = "TABLE_SCHEMA", string name = "TABLE_NAME") { var query = SupportSchema ? from a in table.AsEnumerable() group a by a.Field <string>(schema) + "." + a.Field <string>(name) into g select new { g.Key, Columns = g } : from a in table.AsEnumerable() group a by a.Field <string>(name) into g select new { g.Key, Columns = g }; foreach (var item in query) { if (Objects.TryGetValue(item.Key, out ObjectElement obj)) { foreach (var data in item.Columns) { var typename = Convert.ToString(data[Names.DataType]); if (DataTypes.ContainsKey(typename)) { var clrtype = DataTypes[typename]; var column = creator.CreateColumn(data, clrtype); obj.Columns.Add(column.Name, column); } } } } }
public override DbObjectCollection CreateCollection(IConnectionInformation info) { var collection = new DbObjectCollection(info); var con = collection.Initialization(); var creator = new ColumnCreator(); collection.RegisterObjects(con.GetSchema("Tables"), true); collection.RegisterObjects(con.GetSchema("Views"), false); collection.RegisterMembers(con.GetSchema("Columns"), creator); foreach (var obj in collection.Objects.Values .Where(a => a.Kind == EObjectKind.Table && a.Columns.Values.Count(b => b.IsKey) == 1)) { obj.Columns.Values.Where(a => a.IsKey).Single().ColumnIndex = null; } return(collection); }