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
Message from discussion Add override points for Query transformation and processing per object
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
 
Ted Elliott  
View profile  
 More options Oct 30 2012, 2:04 pm
From: Ted Elliott <elliott....@gmail.com>
Date: Tue, 30 Oct 2012 11:04:50 -0700 (PDT)
Local: Tues, Oct 30 2012 2:04 pm
Subject: Re: Add override points for Query transformation and processing per object

I like the solution but I'm not sure if it would work for us.  We are a
multi-tenant app, and basically the string lookup is backed by another
collection in the mongo database, with a couple of layers of cache
in-between for performance.  The instance of the StringLookup would be
different for each client database we're talking to, so it doesn't look
like it would work to register it in the class map.  Is there a way around
that?

On Tuesday, October 30, 2012 12:03:05 PM UTC-4, Ted Elliott wrote:

> Would it be possible to add some override points in the driver to do Linq
> query transformation as well as some processing done on an object after its
> deserialized but before its returned from the enumerator?  Here is what we
> are trying to accomplish, we have some fields where we've "compressed" some
> strings to save space in the database.  Basically we've taken a string,
> stuck it in a lookup table to get back an int Id and the int gets stored in
> the database.  We would like to put that as close to the database as
> possible to make it more automatic and not require the developer to think
> about it too much.  The object is modeled like this:

> class Foo {
>     [BsonIgnore]
>     [MyCompressedField("BarId")]
>     public string BarString { get; set; }

>     [BsonElement("B")]
>     public int BarId { get; set; }
> }

> So we want to do a few things here:
> 1. Rewrite Linq queries so that when someone does FooCollection.Where(f =>
> f.BarString == "bar"), that is translated to FooCollection.Where(f =>
> f.BarId == 123) which results in the mongo query: "{ B : 123 }". where 123
> is the key for the string "bar".
> 2. As the object comes out of the database repopulate our string field:
>    f => { f.BarString = stringLookup.GetString(f.BarId) }
> 3. Inserts/Updates need to do the reverse:
>    f=> { f.BarId = stringLookup.GetStringId(f.BarString) }

> We have 1 and 2 working, but we've had to wrap the MongoQueryProvider and
> MongoQueryable in odd ways.  The BeginInit/EndInit methods don't really
> work for this scenario as we require a reference to external object to do
> the conversion, and it is not a singleton.

> So could something like this be added so that we have some places to
> register some callbacks to occur?  I would be willing to write the code if
> I could get some pointers as to where the best places to put these would
> be.  I think Item #1 seems like it would go on MongoCollection.  

> Thanks,
> Ted


 
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.