コード例 #1
0
        public static string ReplaceEntityReferencesAndAttributesInOrderBy(IDMLIdentifiers dmlIdentifiers, string paramValue, string[] entityNames, string[] entityAliases, IDictionary <string, string>[] entityNamesToAttributes)
        {
            string          ret;
            MatchCollection mc;
            Match           m;

            paramValue = paramValue.Trim();

            mc = NotAllowedTableNamesRegex.Matches(paramValue);
            if (mc.Count > 0)
            {
                m = mc[0];
                throw new DataBaseException("'" + m.Groups[2] + m.Groups[3] + "' found in 'Order By' parameter is a reserved prefix");
            }

            if (paramValue != "")
            {
                mc = DynOrderByValidateRegex.Matches(paramValue);
                if (mc.Count != 1 || mc[0].Value != paramValue)
                {
                    throw new DataBaseException("Invalid syntax in 'Order By' parameter.");
                }
            }

            MatchEvaluator meReplaceEntityName          = match => ReplaceEntityNameInOrderBy(match, entityNames, entityAliases);
            MatchEvaluator meReplaceEntityAttributeName = match => ReplaceEntityAttributesName(dmlIdentifiers, match, entityNames, entityAliases, entityNamesToAttributes);
            MatchEvaluator meReplaceAttributeName       = match => ReplaceAttributeName(dmlIdentifiers, match);


            ret = EntitiesInOrderByRegex.Replace(paramValue, meReplaceEntityName);
            ret = AliasAttributesRegex.Replace(ret, meReplaceEntityAttributeName);
            ret = AttributesRegex.Replace(ret, meReplaceAttributeName); // replace delimiters in attributes that doesn't belong to any entity
            return(ret);
        }
コード例 #2
0
        public static string ReplaceEntityReferencesInParameter(IDMLIdentifiers dmlIdentifiers, string inParam, bool enableFixLiteralsMisinterpretedAsIdentifiers)
        {
            var mc = NotAllowedTableNamesRegex.Matches(inParam);

            if (mc.Count > 0)
            {
                var m = mc[0];
                throw new DataBaseException("'" + m.Groups[2] + m.Groups[3] + "' found in 'Expand Inline' parameter is a reserved prefix");
            }

            var ret = inParam;

            if (!enableFixLiteralsMisinterpretedAsIdentifiers)
            {
                MatchEvaluator meReplaceAttributeName = match => ReplaceAttributeName(dmlIdentifiers, match);
                ret = AttributesRegex.Replace(ret, meReplaceAttributeName);
            }

            return(ret);
        }
コード例 #3
0
        public static string ReplaceEntityReferencesInParameter(IDMLIdentifiers dmlIdentifiers, string inParam)
        {
            string          ret;
            MatchCollection mc;
            Match           m;

            mc = NotAllowedTableNamesRegex.Matches(inParam);
            if (mc.Count > 0)
            {
                m = mc[0];
                throw new DataBaseException("'" + m.Groups[2] + m.Groups[3] + "' found in 'Expand Inline' parameter is a reserved prefix");
            }

            ret = inParam;
            MatchEvaluator meReplaceAttributeName = match => ReplaceAttributeName(dmlIdentifiers, match);

            ret = AttributesRegex.Replace(ret, meReplaceAttributeName);

            return(ret);
        }