Ejemplo n.º 1
0
        public List <T> ScanTable(string tableName, List <DynamodbScanCondition> saScanConditions = null)
        {
            var          retValue = new List <T>();
            ScanResponse response;

            if (saScanConditions != null)
            {
                var filterConditions = new Dictionary <string, Condition>();
                foreach (var saCondition in saScanConditions)
                {
                    List <AttributeValue> val = new List <AttributeValue>();
                    if (saCondition.Value is List <string> )
                    {
                        foreach (string value in (List <string>)saCondition.Value)
                        {
                            val.Add(new AttributeValue(value));
                        }
                    }
                    else
                    {
                        val.Add(new AttributeValue(saCondition.Value.ToString()));
                    }
                    Condition condition = new Condition()
                    {
                        AttributeValueList = val,
                        ComparisonOperator = ComparisonOperator.FindValue(saCondition.Operator.ToString())
                    };
                    filterConditions.Add(saCondition.AttributeName, condition);
                }
                //var request = new ScanRequest(tableName);


                Table ThreadTable = Table.LoadTable(client, tableName);

                //ScanFilter scanFilter = new ScanFilter();
                //scanFilter.AddCondition("ForumId", ScanOperator.Equal, 101);
                //scanFilter.AddCondition("Tags", ScanOperator.Between, "sortkey");

                response = client.Scan(tableName, filterConditions);
            }
            else
            {
                response = client.Scan(tableName, new Dictionary <string, Condition>());
            }
            foreach (var item in response.Items)
            {
                retValue.Add(ConvertTableItemToInstance(item));
            }
            return(retValue);
        }