public static string GetFieldLabel(this IDynamoCommonQuery q, string field)
        {
            if (!DynamoConfig.IsReservedWord(field))
            {
                return(field);
            }

            var  alias       = "#" + field.Substring(0, 2).ToUpper();
            bool aliasExists = false;

            foreach (var entry in q.ExpressionAttributeNames)
            {
                if (entry.Value == field)
                {
                    return(entry.Key);
                }

                if (entry.Key == alias)
                {
                    aliasExists = true;
                }
            }

            if (aliasExists)
            {
                alias += q.ExpressionAttributeNames.Count;
            }

            q.ExpressionAttributeNames[alias] = field;
            return(alias);
        }
Exemple #2
0
        public string GetMemberName(string memberName)
        {
            if (DynamoConfig.IsReservedWord(memberName) && !visitingExpressionList)
            {
                var  alias       = "#" + memberName.Substring(0, 2).ToUpper();
                bool aliasExists = false;
                foreach (var entry in Aliases)
                {
                    if (entry.Value == memberName)
                    {
                        return(entry.Key);
                    }
                    if (entry.Key == alias)
                    {
                        aliasExists = true;
                    }
                }

                if (aliasExists)
                {
                    alias += Aliases.Count;
                }

                Aliases[alias] = memberName;
                return(alias);
            }

            return(memberName);
        }