[CSHARP-433] Support OfType LINQ query operator Created: 04/Apr/12  Updated: 02/Apr/15  Resolved: 13/Apr/12

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.4
Fix Version/s: 1.4.1

Type: New Feature Priority: Minor - P4
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CSHARP-631 Update LINQ supported features docume... Closed

 Description   

Assume D is a subclass of C:

var query = collection.AsQueryable<C>().OfType<D>();

or using query syntax and type comparisons support either of the following:

var query = from c in collection.AsQueryable<C>() where c is D select c;
var query = from c in collection.AsQueryable<C>() where c.GetType() == typeof(D) select c;

The second example differs slightly in that it should not match subclasses of D.

These would be translated into queries against the "_t" discriminator value.



 Comments   
Comment by Craig Wilson [ 26/Jan/13 ]

Yes, we have an open ticket to update the linq documentation. Thanks for reporting.

Comment by Ian Mercer [ 25/Jan/13 ]

The documentation at (http://www.mongodb.org/display/DOCS/CSharp+Driver+LINQ+Tutorial) doesn't mention 'OfType()' should it?

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