Closed diogonborges closed 2 years ago
Hmm This doesn't quite look right 🤔 I tried replicating this behavior to no avail:
provider.Connection.CreateIndex(typeof(Model));
collection.Insert(new Model(){Id = "ARandomValidId"});
try
{
collection.FirstOrDefault(x => x.Id == "ARandomValidId");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Is there something else I'm missing Maybe?
What version of .NET are you on? What version of redis OM are you using?
Hey @slorello89! After a lot of trial and testing I've found it! :O
if (hash.Any<KeyValuePair<string, string>>((Func<KeyValuePair<string, string>, bool>) (x => x.Key.StartsWith(propertyName))))
This causes a problem when we have multiple properties with the same start of the string propertyName.
Example:
[Document(IndexName = "employees_idx", StorageType = StorageType.Hash)]
public class Employee
{
[Searchable(Sortable = true)] public string Name { get; set; }
[Searchable(Aggregatable = true)] public string Location { get; set; }
[Searchable(Aggregatable = true)] public int? LocationNumber { get; set; }
}
var provider = new RedisConnectionProvider(RedisConnectionString);
var employees = provider.RedisCollection<Employee>();
provider.Connection.DropIndexAndAssociatedRecords(typeof(Employee));
provider.Connection.CreateIndex(typeof(Employee));
employees.Insert(new Employee { Name = "Bob", LocationNumber = 10});
var first = employees.FirstOrDefault(x=>x.Name == "Bob");
Got this error when using Redis Enterprise on Azure
and running the following line:
The model is
The line of code that throws exception
This happens because I've stored a hash entry that does not contain that string property and then when retrieving, the Json conversion looks to be failing.
Thanks!