private List <TableInfo> InitializeFromTables() { List <TableInfo> result = new List <TableInfo>(); var rtes = jObject.SelectTokens("..RTE"); foreach (var rte in rtes) { var rteKind = EnumParsingSupport.ConvertFromNumericOrDefault <RteKind>(rte.SelectToken("rtekind").Value <int>()); if (rteKind == RteKind.Relation) { var relKind = EnumParsingSupport.ConvertFromStringOrDefault <RelKind>(rte.SelectToken("relkind").Value <string>()); if (relKind == RelKind.Relation) { TableInfo toAdd = new TableInfo(); toAdd.ID = rte.SelectToken("relid").Value <long>(); var table = PostgresData.Instance.PgClasses.Where(x => x.oid == toAdd.ID).First(); toAdd.Name = table.relname; var schema = PostgresData.Instance.PgNamespaces.Where(x => x.oid == table.relnamespace).First(); toAdd.SchemaName = schema.nspname; result.Add(toAdd); } } } return(result); }
private List <JoinInfo> InitializeJoins() { List <JoinInfo> result = new List <JoinInfo>(); var joins = jObject.SelectTokens("..JOINEXPR"); foreach (var join in joins) { var toAdd = new JoinInfo(); toAdd.Type = EnumParsingSupport.ConvertFromNumericOrDefault <JoinType>(join.SelectToken("jointype").Value <int>()); var index = join.SelectToken("larg").SelectToken("RANGETBLREF").SelectToken("rtindex").Value <int>() - 1; toAdd.LeftRelation = FromTables[index]; index = join.SelectToken("rarg").SelectToken("RANGETBLREF").SelectToken("rtindex").Value <int>() - 1; toAdd.RightRelation = FromTables[index]; toAdd.Predicates.AddRange(InitializePredicates("..JOINEXPR.quals")); result.Add(toAdd); } return(result); }
private CmdType InitializeCommandType() { var cmdType = jObject.SelectToken("QUERY.commandType"); return(EnumParsingSupport.ConvertFromNumericOrDefault <CmdType>(cmdType.Value <int>())); }