Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
C# Driver, using linq's In operater ($in) for regex
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sam Martin  
View profile  
 More options Oct 8 2012, 4:44 pm
From: Sam Martin <sambomar...@gmail.com>
Date: Mon, 8 Oct 2012 13:44:09 -0700 (PDT)
Local: Mon, Oct 8 2012 4:44 pm
Subject: C# Driver, using linq's In operater ($in) for regex

Hi all,

think this should be a simple one, but cant suss the syntax.

In mongo i can say

db.coll.find({ "myatt": { $in : [/^x/,/^y/]} });

Is this possible using the "In" linq to mongo extension method?

I've tried passing the string[] as regex string but no surprise didn't
work, do I have to use Inject()?

TIA
Sam


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Stam  
View profile  
 More options Oct 8 2012, 5:06 pm
From: Robert Stam <rob...@10gen.com>
Date: Mon, 8 Oct 2012 17:05:59 -0400
Local: Mon, Oct 8 2012 5:05 pm
Subject: Re: [mongodb-user] C# Driver, using linq's In operater ($in) for regex

This can't really be expressed in standard LINQ because the types involved
(string and BsonRegularExpression) are different. The standard LINQ
Contains extension method (and the analogous LINQ to MongoDB In extension
method) assumes that the value being tested and the source of values to
test against are of the same type.

Inject seems like a good workaround.

Do you feel there should be a way to express this type-mismatched query
directly in LINQ to MongoDB? If so, you could create a new JIRA issue
requesting the feature.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options Oct 8 2012, 5:19 pm
From: craiggwilson <craiggwil...@gmail.com>
Date: Mon, 8 Oct 2012 14:19:39 -0700 (PDT)
Local: Mon, Oct 8 2012 5:19 pm
Subject: Re: [mongodb-user] C# Driver, using linq's In operater ($in) for regex

JIRA already exists: https://jira.mongodb.org/browse/CSHARP-495 and a
related issue https://jira.mongodb.org/browse/CSHARP-493.  I have the code
done for the fix, but we weren't (and still aren't) sure if this is
supposed to work or if it just happens to work (and might go away later).

https://github.com/craiggwilson/mongo-csharp-driver/tree/csharp493_495


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AG  
View profile  
 More options Oct 30 2012, 9:16 pm
From: AG <agarcia...@gmail.com>
Date: Tue, 30 Oct 2012 18:16:00 -0700 (PDT)
Subject: Re: C# Driver, using linq's In operater ($in) for regex

Is there a way to express the $in query using regular expressions in the c#
driver?

Something like this, but checking the regex against any member in the array?

Query.Matches("Series", BsonRegularExpression.Create(new
Regex(searchPattern, RegexOptions.IgnoreCase)))

Thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Martin  
View profile  
 More options Oct 30 2012, 9:31 pm
From: Sam Martin <sambomar...@gmail.com>
Date: Wed, 31 Oct 2012 01:30:27 +0000
Local: Tues, Oct 30 2012 9:30 pm
Subject: Re: [mongodb-user] Re: C# Driver, using linq's In operater ($in) for regex

here's one i've used a bit.

It returns documents where one of the elements in the series array exists
in an collection of regular expressions created from a string array.

i.e. all docs where at least one of the Series elements starts with one of
the items in my string array. /^xxxx/, /^yyyy/

_db.GetCollection("mycollection").Find(Query.In("Series"
, mystringrray.Select(p => BsonRegularExpression.Create("/^" + p + "/")));

does that help?

On 31 October 2012 01:16, AG <agarcia...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »