[CSHARP-63] LINQ Support for All() subquery Created: 13/Sep/10  Updated: 18/Sep/10  Resolved: 18/Sep/10

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

Type: New Feature Priority: Major - P3
Reporter: Oliver Weichhold Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

It would nice if the LINQ Provider would offer support for List<T>.TrueForAll(), Enumerable.All() or both so that something like the sample below would work out of the box:

class Post
{
string Title;
string Body;
List<string> Tags;
}

This SearchByTag is supposed to search for all Posts containing ALL the tags.

public List<Snip> SearchByTag(List<string> Tags, int PageSize, int
StartPage, int PageCount)
{
using (var db = ServiceLocator.Get<IMongo>())

{ var posts = db.GetCollection<Post>(); List<Post> result; int skip = StartPage*PageSize; int take = PageCount*PageSize; if (Tags != null && Tags.Count > 0) result = posts.AsQueryable().Where(x => Tags.All(x.Tags.Contains)).OrderByDescending(x => x.LastAccess).Skip(skip).Take(take).ToList(); else result = posts.AsQueryable().OrderByDescending(x => x.LastAccess).Skip(skip).Take(take).ToList(); return result; }

 Comments   
Comment by Craig Wilson [ 18/Sep/10 ]

I have added this support into my branch http://github.com/craiggwilson/mongodb-csharp/tree/1.6_prep. It will get merged at some point into the master.

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