[QUESTION] Difficulty Querying with Composite Index
mirror222 opened this issue · 0 comments
mirror222 commented
hi,
I'm facing an issue with querying using a composite index. I have a User class defined as follows:
public class User
{
[BsonId]
public int UID { get; set; }
public string UserId { get; set; } = "";
public long Amount { get; set; } = 0;
}
I created a composite index in LiteDB like this:
db.EnsureIndex("uIndex", x => x.UserName + x.Amount.ToString(), true);
Here is some sample data in the database:
1 "Ben" 64
2 "Jemmy" 193
Now, when I try to query the data using the following statement, I'm unable to retrieve any results:
var u = db.FindOne(x => (x.UserName + x.Amount.ToString()) == "Ben64");
I would appreciate any insights or suggestions on why the query might not be working as expected.
Thanks in advance for your help!