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 CSharp Driver: Problem querying Guid Id represented as String in subclass
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
 
Christian Sparre  
View profile  
 More options Oct 5 2012, 3:55 am
From: Christian Sparre <christ...@sparre.it>
Date: Fri, 5 Oct 2012 00:55:30 -0700 (PDT)
Local: Fri, Oct 5 2012 3:55 am
Subject: Re: CSharp Driver: Problem querying Guid Id represented as String in subclass

I'm using version 1.6 installed via nuget.

I just made a test with Id's stored the default way (BinData(3.....)) and
it works fine when querying with Linq

/Christian

Den torsdag den 4. oktober 2012 17.36.26 UTC+2 skrev craiggwilson:

> Was just talking about this with Robert and I may have misunderstood your
> question.  You may have hit this bug (which has been fixed for a little
> while): https://jira.mongodb.org/browse/CSHARP-418.  What version of the
> driver are using?

> On Thursday, October 4, 2012 8:46:15 AM UTC-5, craiggwilson wrote:

>> You need to access the collection using the base class and then us OfType
>> to add the type restriction.

>> Colleciton<Element>.AsQueryable().OfType<Survey>().Where(f => f.Id == id);

>> On Thursday, October 4, 2012 6:02:21 AM UTC-5, Christian Sparre wrote:

>>> I have a base class *Element *and a subclass *Survey*

>>> In simple form they look like this :)

>>> Element
>>> {
>>>   Guid Id;
>>> }

>>> Survey : Element
>>> {
>>>   String Title;
>>> }

>>> The *Guid Id* is represented as a string in the database using the
>>> [BsonRepresentation(BsonType.String)] attribute

>>> When I save documents and return them all (FindAll) everything works
>>> fine and they are serialized and deserialized as expected.

>>> But when I try to do the following it fails with the error *"Unable to
>>> determine the serialization information for the expression: f.Id"*

>>> Collection<*Survey*>.AsQueryalble().Where(f=>f.Id == id)

>>> But if I query only on the base class *Element*

>>> Collection<*Element*>.AsQueryalble().Where(f=>f.Id == id) it works as
>>> expected.

>>> I have no class maps created manually, and when I lookup the *Survey *class
>>> map the *Id *property seems to be mapped correctly with the string
>>> representation

>>> Any idea?, I know there was a problem with inherited properties and
>>> querying, but that was a long time ago. Also before I changed the
>>> representation to string I had no problems.

>>> --
>>> Christian


 
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.