public MSRAEntityManager(string serverName)
 {
     MsraSqlConn = new SQLConn(ServerName, "MsrMetadata");
     ServerName = serverName;
     InsertQuery = new Dictionary<string, string>();
     SelectQuery = new Dictionary<string, string>();
     LoadSelectAndInsertSqlQueries();
 }
        public void LoadMsrFields(string ServerName)
        {
            Console.WriteLine("Loading Fields of Folders from database schema...");
            var sqlConn = new SQLConn(ServerName, WarehouseDBName);
            Dictionary<string, Dictionary<string, string>> fieldInfoList = null;
            if (!TxtInput[2].Trim().StartsWith("SELECT *"))
            {
                fieldInfoList = RetrieveParenthesisEnclosedDataFor("SELECT");
            }

            foreach (KeyValuePair<string, FolderInfo> fItem in FolderList)
            {
                string tableAlias = fItem.Key;
                FolderInfo fInfo = fItem.Value;
                string query = String.Format("SELECT Column_Name, Data_Type FROM Information_Schema.Columns WHERE Table_Name = '{0}'", fInfo.TableName);
                DataTable dt = sqlConn.ExecuteQuery(query);
                foreach (DataRow row in dt.Rows)
                {                                                            
                    string columnName = row["Column_Name"].ToString();
                    string dataType = row["Data_Type"].ToString();
                    if (TxtInput[2].StartsWith("SELECT ALL"))
                    {                        
                        if (fieldInfoList[tableAlias].ContainsKey(columnName))                        
                            fItem.Value.FieldList.Add(new FieldInfo(columnName, dataType, fieldInfoList[fItem.Key][columnName]));                        
                        else
                            fItem.Value.FieldList.Add(new FieldInfo(columnName, dataType));
                    }
                    else if (TxtInput[2].StartsWith("SELECT ONLY"))
                    {
                        if (fieldInfoList[tableAlias].ContainsKey(columnName))                        
                            fItem.Value.FieldList.Add(new FieldInfo(columnName, dataType, fieldInfoList[fItem.Key][columnName]));
                    }
                    else if (TxtInput[2].StartsWith("SELECT ALL EXCEPT"))
                    {
                        if (!fieldInfoList[tableAlias].ContainsKey(columnName))
                            fItem.Value.FieldList.Add(new FieldInfo(columnName, dataType, fieldInfoList[fItem.Key][columnName]));
                    }
                    else // SELECT * 
                    {
                        fItem.Value.FieldList.Add(new FieldInfo(columnName, dataType));
                    }
                }
            }
        }