I have a user table with following attributes:
- FirstName
- LastName
- City
- CompanyName
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?