예제 #1
0
        private string GetDaxName()
        {
            const string VALID_NAME_START    = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
            const string STANDARD_NAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789";

            bool   goodFirstCharacter  = VALID_NAME_START.IndexOf(Name[0]) >= 0;
            bool   noSpecialCharacters = Name.Where((c) => STANDARD_NAME_CHARS.IndexOf(c) < 0).Count() == 0;
            string nameUpper           = Name.ToUpper();
            //bool noSpecialName = specialNames.Where((s) => s == nameUpper).Count() == 0;
            bool noSpecialName = !(_adoTabConn.Keywords.Contains(nameUpper) || _adoTabConn.AllFunctions.Contains(nameUpper));

            if (Name.Length > 0 &&
                goodFirstCharacter &&
                noSpecialCharacters &&
                noSpecialName)
            {
                return(Name);
            }
            else
            {
                return(string.Format("'{0}'", Name));
            }
        }
예제 #2
0
        private string GetDaxName()
        {
            const string VALID_NAME_START    = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
            const string STANDARD_NAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789";

            bool goodFirstCharacter  = VALID_NAME_START.IndexOf(Name[0]) >= 0;
            bool noSpecialCharacters = Name.Where((c) => STANDARD_NAME_CHARS.IndexOf(c) < 0).Count() == 0;
            //string nameUpper = Name.ToUpper();
            //bool noSpecialName = specialNames.Where((s) => s == nameUpper).Count() == 0;
            bool noSpecialName = !(_adoTabConn.Keywords.Contains(Name, StringComparer.OrdinalIgnoreCase) || _adoTabConn.AllFunctions.Contains(Name, StringComparer.OrdinalIgnoreCase));

            if (Name.Length > 0 &&
                goodFirstCharacter &&
                noSpecialCharacters &&
                noSpecialName)
            {
                return(Name);
            }
            else
            {
                // need to double up any single quote characters
                return(string.Format("'{0}'", Name.Replace("'", "''")));
            }
        }