public static void transCreateTable(TableManager tableManager, SqlGrammar.Sql_Table table) { List <string> order = new List <string>(Constants.MAX_ATTR_NUM); if (table != null) { Dictionary <string, TableAttribute> atributes = new Dictionary <string, TableAttribute>(Constants.MAX_ATTR_NUM); foreach (var item in table.tableAttributes) { order.Add(item.name); Parser.println("type = " + item.type); switch (item.type) { case "int": item.type = "Int32"; break; case "varchar": item.type = "String"; break; } Parser.println("size = " + item.maxStringLength); atributes.Add(item.name, new TableAttribute(item.type, item.isPrimary, item.maxStringLength)); } tableManager.createTable(table.name, order, atributes); } }
public static KeyValuePair <string, dynamic> sql_selector(string sql) { string[] seperated_query = sql.Split(); if (string.Compare(seperated_query[0].ToLower(), "create", true) == 0) { SqlGrammar.Sql_Table table = CreateTable(sql); return(new KeyValuePair <string, dynamic>("create", table)); } else if (string.Compare(seperated_query[0].ToLower(), "insert", true) == 0) { //Console.WriteLine("Inserting"); SqlGrammar.Sql_Insertion Insertion = Insert(sql); return(new KeyValuePair <string, dynamic>("Inserting", Insertion)); //public string table; //public List<string> AttrNames; //public List<dynamic> AttrValues; } else if (string.Compare(seperated_query[0].ToLower(), "select", true) == 0) { //Console.WriteLine("Inserting"); SqlObjects.Sql_Select selection = Parser.Select(sql + ";"); return(new KeyValuePair <string, dynamic>("select", selection)); //public string table; //public List<string> AttrNames; //public List<dynamic> AttrValues; } else if (string.Compare(seperated_query[0].ToLower(), "create index") == 0) { SqlObjects.SQL_Index Indexing = Parser.Index(sql); return(new KeyValuePair <string, dynamic>("index", Indexing)); } else { if (sql == string.Empty) { return(new KeyValuePair <string, dynamic>("empty", null)); } else { return(new KeyValuePair <string, dynamic>("unKnown", null)); } } }