[CSHARP-1635] Create a filter builder method generic enough to allow multiple similar types to be used Created: 21/Apr/16  Updated: 17/May/16  Resolved: 16/May/16

Status: Closed
Project: C# Driver
Component/s: API
Affects Version/s: 2.2.3
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Chad Kreimendahl Assignee: Unassigned
Resolution: Won't Fix Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CSHARP-1668 Allow FilterDefinition OfType to allo... Closed

 Description   

We have a collection that stores many object types. While they're all rooted around the same base class, we occasionally want AND together FilterDefinitions from multiple related classes. It would be great to have a generic FilterBuilder that would allow the Anding' together of unique types of FilterDefinition types without getting angry.

Previously we could

Query.And(Query<Email>.EQ(linqdef), Query<PasswordEmail>.EQ(linqdef2))

and get back a basic IMongoQuery, on which we could do some further things like sorting, etc.

This let us have a series of logic points and inject find parameters for different types and get the expected result. Given that multiple types can reside in one collection (and thus could be supported in 1 FilterDefinition), there should be a less rigid method for cases where this is the desired outcome.

It would be useful for it to work when using the "&" or "|" methods as well.



 Comments   
Comment by Chad Kreimendahl [ 17/May/16 ]

In this event 1668 should work for us.... and PasswordEmail inherits from Email... which was what we wanted to get... the ability to query subtypes with ANDs

Comment by Craig Wilson [ 16/May/16 ]

Hi Chad,

The only way this will work in the new API is for each type to have a common base class and couple that with CSHARP-1668. It is highly uncommon to store multiple unrelated items in a single collection and, if that happens to be the case, then using BsonDocument or simply "object" will be the only way to handle that.

I'm going to close this one as won't fix, but link it to 1668.

Craig

Generated at Wed Feb 07 21:40:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.