Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-5161

Add support for Scalar Value Objects

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 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

            Assignee:
            Unassigned Unassigned
            Reporter:
            rishit.bhatia@mongodb.com Rishit Bhatia
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: