Exemplo n.º 1
0
        public async Task List()
        {
            Console.WriteLine("Entering List");
            var description = await DescribeTable();

            Console.WriteLine($"Table name: {description.TableName}" + "  " + $"Table status: {description.TableStatus}");

            Table QTable = Table.LoadTable(client, ClientTableName);
            //get the RequestQ items for the ClientGuid
            ScanFilter scanFilter = new ScanFilter();

            scanFilter.AddCondition("ClientID", ScanOperator.GreaterThan, " ");
            ScanOperationConfig config = new ScanOperationConfig()
            {
                Filter = scanFilter,
            };

            Search          search   = QTable.Scan(scanFilter);
            List <Document> allItems = await search.GetRemainingAsync();

            Console.WriteLine("================================================================================");
            foreach (Document doc in allItems)
            {
                foreach (string itemkey in doc.Keys)
                {
                    DynamoDBEntry dbEntry = doc[itemkey];

                    if (itemkey == "ClientID")
                    {
                        string val = dbEntry.AsString(); Console.WriteLine("ClientID:         " + val);
                    }
                    if (itemkey == "ClientGuid")
                    {
                        string val = dbEntry.AsString(); Console.WriteLine("ClientGuid:       " + val);
                    }
                    if (itemkey == "ActiveStatus")
                    {
                        bool val = dbEntry.AsBoolean(); Console.WriteLine("ActiveStatus:     " + val);
                    }
                    if (itemkey == "secret")
                    {
                        string val = dbEntry.AsString(); Console.WriteLine("secret:           " + val);
                    }
                    if (itemkey == "amazn_link_time")
                    {
                        string val = dbEntry.AsString(); Console.WriteLine("amazn_link_time:  " + val);
                    }
                    if (itemkey == "Appliance")
                    {
                        int i = 0; foreach (string device in dbEntry.AsListOfString())
                        {
                            Console.WriteLine("Appliance(" + i + "):     " + device); i++;
                        }
                    }
                }// end foreach key

                Console.WriteLine("================================================================================");
            }
            return;
        }
 public static bool?AsBooleanOrDefault(this DynamoDBEntry o)
 {
     if (o == null)
     {
         return(null);
     }
     else
     {
         return(o.AsBoolean());
     }
 }
Exemplo n.º 3
0
 public object FromEntry(DynamoDBEntry entry)
 {
     if (entry is null)
     {
         return(null);
     }
     if (entry is DynamoDBBool)
     {
         return(entry.AsBoolean());
     }
     return(bool.Parse(entry.AsString()));
 }
Exemplo n.º 4
0
 public static object AsType(this DynamoDBEntry entry, Type type)
 {
     if (type == stringType)
     {
         return(entry.AsString());
     }
     else if (type == intType)
     {
         return(entry.AsInt());
     }
     else if (type == boolType)
     {
         return(entry.AsBoolean());
     }
     else if (type == longType)
     {
         return(entry.AsLong());
     }
     else if (type == dateTimeType)
     {
         return(entry.AsDateTime());
     }
     else if (type == doubleType)
     {
         return(entry.AsDouble());
     }
     else if (type == floatType)
     {
         return(entry.AsSingle());
     }
     else if (type == listOfStringType)
     {
         return(entry.AsListOfString());
     }
     else if (type == listOfByteArrayType)
     {
         return(entry.AsListOfString());
     }
     return(null);
 }
Exemplo n.º 5
0
        public static T Convert <T>(DynamoDBEntry entry)
        {
            Type type = typeof(T);

#pragma warning disable IDE0011 // Add braces
            if (type == typeof(bool))
            {
                return((T)(object)entry.AsBoolean());
            }
            if (type == typeof(byte))
            {
                return((T)(object)entry.AsByte());
            }
            if (type == typeof(byte[]))
            {
                return((T)(object)entry.AsByteArray());
            }
            if (type == typeof(char))
            {
                return((T)(object)entry.AsChar());
            }
            if (type == typeof(DateTime))
            {
                return((T)(object)entry.AsDateTime());
            }
            if (type == typeof(decimal))
            {
                return((T)(object)entry.AsDecimal());
            }
            if (type == typeof(double))
            {
                return((T)(object)entry.AsDouble());
            }
            if (type == typeof(Guid))
            {
                return((T)(object)entry.AsGuid());
            }
            if (type == typeof(int))
            {
                return((T)(object)entry.AsInt());
            }
            if (type == typeof(long))
            {
                return((T)(object)entry.AsLong());
            }
            if (type == typeof(MemoryStream))
            {
                return((T)(object)entry.AsMemoryStream());
            }
            if (type == typeof(sbyte))
            {
                return((T)(object)entry.AsSByte());
            }
            if (type == typeof(short))
            {
                return((T)(object)entry.AsShort());
            }
            if (type == typeof(float))
            {
                return((T)(object)entry.AsSingle());
            }
            if (type == typeof(string))
            {
                return((T)(object)entry.AsString());
            }
            if (type == typeof(uint))
            {
                return((T)(object)entry.AsUInt());
            }
            if (type == typeof(ulong))
            {
                return((T)(object)entry.AsULong());
            }
            if (type == typeof(ushort))
            {
                return((T)(object)entry.AsUShort());
            }
#pragma warning restore IDE0011 // Add braces
            throw new InvalidOperationException($"{type.FullName} is not supported as aggregate key in DynamoDB");
        }