-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Linq, Serialization
-
None
-
Dotnet Drivers
As a developer, I would like to be able to have ValueObjects with primitives in my model class so that I can query them correctly and get expected responses.
This includes having the ability to use
public sealed class Age : PrimitiveValueObject<Age, int> { /// <inheritdoc /> public Age(int value) : base(value) { } }
with base classes such as
public class Person { public ObjectId Id { get; set; } public string Name { get; set; } public Age Age { get; set; } }
So that queries like the following can be executed with expected responses
Person stringFilterResult = await collection .Find(Builders<Person>.Filter.Lt("Age.Value", 40)).FirstOrDefaultAsync();
Person expressionFilterResult = await collection .Find(Builders<Person>.Filter.Lt(p => p.Age.Value, 40)).FirstOrDefaultAsync();
Person linqFilterResult = await collection.AsQueryable().Where(x => x.Age.Value < 40) .FirstOrDefaultAsync();
Details mentioned in the post here