-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Scan with Multiple Conditions #2987
Comments
Hi @jbtamaresgit, Good morning. Thanks for reporting the issue. Unfortunately, I'm unable to reproduce the issue. For Object Persistence model, you would need to use convertor to convert between For the example table schema shared by you, the below code works fine (2 results are returned; where I created 3 items with one of them having using System;
using System.Collections.Generic;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DataModel;
using Amazon.DynamoDBv2.DocumentModel;
using Amazon.Runtime;
using (AmazonDynamoDBClient client = new AmazonDynamoDBClient())
{
DynamoDBContext context = new DynamoDBContext(client, new DynamoDBContextConfig() { Conversion = DynamoDBEntryConversion.V2 });
if (context != null)
{
List<ScanCondition> scanConditions = new List<ScanCondition>
{
new ScanCondition("SortKey", ScanOperator.Equal, "sk1"),
new ScanCondition("TestBool", ScanOperator.Equal, new DynamoDBBool(true))
};
var scanResponse = await context.ScanAsync<TestTable>(scanConditions).GetRemainingAsync();
}
}
[DynamoDBTable("TestTable")]
public class TestTable
{
[DynamoDBHashKey]
public string Id { get; set; }
[DynamoDBRangeKey]
public string SortKey { get; set; }
[DynamoDBProperty("TestBool", typeof(DynamoDBNativeBooleanConverter))]
public bool TestBool { get; set; }
}
public class DynamoDBNativeBooleanConverter : IPropertyConverter
{
public DynamoDBEntry ToEntry(object value)
{
DynamoDBEntry entry = DynamoDBNull.Null;
if (value != null)
{
if (value is DynamoDBBool)
{
entry = (DynamoDBBool) value;
}
else
{
entry = new DynamoDBBool(bool.TryParse(value?.ToString(), out var val) && val);
}
}
return entry;
}
public object FromEntry(DynamoDBEntry entry)
{
return entry.AsDynamoDBBool().Value;
}
} Thanks, |
Hi @ashishdhingra ,
And that should not be a problem since I can comment out the
I also did try this, but it did not work as well. Does the conversion for the Update: Code snippet for
Fetching of items is still the same
|
@jbtamaresgit Good morning. I was also using the same converter as you, but since you are using Thanks, |
Hi @ashishdhingra , |
|
Describe the bug
Hi,
I was unable to scan objects with multiple conditions using
ScanAsync
below is the code snippet:And below I have these in my table:
Below is the result of the debug:
Removing one of the conditions will give me results:
Expected Behavior
Return based on the scan conditions
Current Behavior
Did not return
Reproduction Steps
Add multiple conditions on scan conditions list
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.AmazonDynamoDBv2 3.7.103.21
Targeted .NET Platform
.NET 7
Operating System and version
Windows 10
The text was updated successfully, but these errors were encountered: