I have a user table with following attributes:
I want to query the table with any combination of these attributes and that too partial .
For example: Input - Firstname- "bh" and lastname - "ta" Output -A Record with FirstName "aBHishek" , lastName"gupTA"
How do I do this query without using scan? Does using scanconditions with contains means the read operation is less costly?
I have tried this in C#:
var conditions = new List<ScanCondition>();
if (!string.IsNullOrEmpty(user.FirstName))
{
var firstName = new ScanCondition("SearchFirstName", ScanOperator.Contains, user.FirstName.ToLower());
conditions.Add(firstName);
}
if (!string.IsNullOrEmpty(user.LastName))
{
var lastName = new ScanCondition("SearchLastName", ScanOperator.Contains, user.LastName.ToLower());
conditions.Add(lastName);
}
var allUsers = await _context.ScanAsync<OpenOrderUser>(conditions).GetRemainingAsync();
return allUsers;
it does the trick but I want to move away from Scan and use Query, any suggestions? is this approach optimal?
Another option you have to retrieve data from an Amazon DynamoDB table when using the AWS SDK for .NET V3 is to use PartiQL. This lets you use SELECT statements to retrieve data from a table in Amazon DynamoDB. Its similiar to SQL.
You can read more here:
PartiQL select statements for DynamoDB
YOu can find full .NET Code example here: