Example #1
0
        public void AddPropertyStorage(PropertyStorage value)
        {
            string propertyName  = value.PropertyName;
            string attributeName = value.AttributeName;

            PropertyToPropertyStorageMapping[propertyName] = value;
            if (!AttributesToGet.Contains(attributeName))
            {
                AttributesToGet.Add(attributeName);
            }
            if (value.IsLSIRangeKey)
            {
                List <string> indexes;
                if (!AttributeToIndexesNameMapping.TryGetValue(attributeName, out indexes))
                {
                    indexes = new List <string>();
                    AttributeToIndexesNameMapping[attributeName] = indexes;
                }
                foreach (var index in value.Indexes)
                {
                    if (!indexes.Contains(index))
                    {
                        indexes.Add(index);
                    }
                }

                foreach (var index in value.Indexes)
                {
                    List <string> properties;
                    if (!IndexNameToRangePropertiesMapping.TryGetValue(index, out properties))
                    {
                        properties = new List <string>();
                        IndexNameToRangePropertiesMapping[index] = properties;
                    }
                    properties.Add(propertyName);
                }
            }
            if (value.IsHashKey)
            {
                HashKeyPropertyNames.Add(propertyName);
            }
            if (value.IsRangeKey)
            {
                RangeKeyPropertyNames.Add(propertyName);
            }
            if (value.IsVersion)
            {
                if (!string.IsNullOrEmpty(VersionPropertyName))
                {
                    throw new InvalidOperationException("Multiple version attributes defined");
                }
                VersionPropertyName = propertyName;
            }
        }
Example #2
0
        private void AddPropertyStorage(PropertyStorage value)
        {
            string propertyName  = value.PropertyName;
            string attributeName = value.AttributeName;

            //PropertyToPropertyStorageMapping[propertyName] = value;
            AddPropertyStorage(propertyName, value);
            if (!AttributesToGet.Contains(attributeName))
            {
                AttributesToGet.Add(attributeName);
            }
            if (value.StoreAsEpoch)
            {
                AttributesToStoreAsEpoch.Add(attributeName);
            }

            if (value.IsLSIRangeKey || value.IsGSIKey)
            {
                List <string> indexes;
                if (!AttributeToIndexesNameMapping.TryGetValue(attributeName, out indexes))
                {
                    indexes = new List <string>();
                    AttributeToIndexesNameMapping[attributeName] = indexes;
                }
                foreach (var index in value.IndexNames)
                {
                    if (!indexes.Contains(index))
                    {
                        indexes.Add(index);
                    }
                }
            }
            if (value.IsHashKey)
            {
                HashKeyPropertyNames.Add(propertyName);
            }
            if (value.IsRangeKey)
            {
                RangeKeyPropertyNames.Add(propertyName);
            }
            if (value.IsVersion)
            {
                if (!string.IsNullOrEmpty(VersionPropertyName))
                {
                    throw new InvalidOperationException("Multiple version properties defined: " + VersionPropertyName + " and " + propertyName);
                }
                VersionPropertyName = propertyName;
            }
        }