Thanks for pointing that out, and in under 15 minutes of me asking. You
nailed the exact problem.
On Mon, Dec 13, 2010 at 9:31 AM, Robert Stam <rstam10
...@gmail.com> wrote:
> There is probably a mismatch between the data in the database and your
> class definition. My guess is that in your class you declared the Id
> field to be of type string, but in the database it is an ObjectId.
> Can you share the declaration of your AdminUser class and also the
> contents of the document in the database using the mongo shell:
> > db.users.find({"Username" : "xyz"})
> Comparing the two should reveal the cause of your error message.
> On Dec 13, 10:18 am, Joseph Good <joe.d.g...@gmail.com> wrote:
> > If it matters, the FindOneAs<AdminUser> also fails when applied to the
> > non-typed collection.
> > On Mon, Dec 13, 2010 at 9:15 AM, Joe <joe.d.g...@gmail.com> wrote:
> > > Please forgive me if this is the wrong group. I'm still not 100%
> > > clear on which group is for the Samus C# driver and which is for the
> > > 10gen driver.
> > > I am having a hard time figuring out an error querying the DB.
> > > I am trying to get a single result out of a typed collection:
> > > // works
> > > var w = Database.GetCollection( Table.Names.ADMIN_USERS );
> > > var x = w.FindOne( Query.EQ( "Username", username ) );
> > > // does not work
> > > var y = Database.GetCollection<AdminUser>( Table.Names.ADMIN_USERS );
> > > var z = y.FindOne( Query.EQ( "Username", username ) );
> > > I get the following:
> > > System.InvalidOperationException: ReadString cannot be called when
> > > BsonType is: ObjectId
> > > Thanks,
> > > Joe