Esempio n. 1
0
        public static void Set <T>(this ITable table, IEnumerable <KeyValuePair <string, T> > items, bool deleteEmpty)
            where T : IEnumerable <KeyValuePair <string, string> >
        {
            var batchPutItems = items.Where(item => !string.IsNullOrEmpty(item.Key)).Select(item =>
                                                                                            new KeyValuePair <string, KeyValuePair <string, string>[]>(item.Key, item.Value.Where(pair =>
                                                                                                                                                                                  !string.IsNullOrEmpty(pair.Key)).ToArray())).Where(item => item.Value.Length != 0).ToArray();

            if (batchPutItems.Length != 0)
            {
                table.BatchPut(w =>
                {
                    foreach (var item in batchPutItems)
                    {
                        foreach (var attribute in item.Value)
                        {
                            w.ReplaceAttribute(item.Key, attribute.Key, attribute.Value != null ? attribute.Value : string.Empty);
                        }
                    }
                });
            }

            if (deleteEmpty)
            {
                var deleteItems = items.Where(item => !string.IsNullOrEmpty(item.Key)).Select(item =>
                                                                                              new KeyValuePair <string, string[]>(item.Key, item.Value.Where(pair =>
                                                                                                                                                             !string.IsNullOrEmpty(pair.Key) && string.IsNullOrEmpty(pair.Value)).Select(pair => pair.Key).ToArray())).Where(item =>
                                                                                                                                                                                                                                                                             item.Value.Length != 0).ToArray();

                if (deleteItems.Length != 0)
                {
                    foreach (var item in deleteItems)
                    {
                        if (item.Value.Length != 0)
                        {
                            table.Delete(item.Key, w =>
                            {
                                foreach (var name in item.Value)
                                {
                                    w.DeleteAttribute(name);
                                }
                            });
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public void BatchPut(Action <IBatchPutWriter> action)
 {
     AmazonReliability.Execute(() => { _table.BatchPut(action); });
 }
Esempio n. 3
0
 public void BatchPut(Action <IBatchPutWriter> action)
 {
     Delay();
     _table.BatchPut(action);
 }