Input string was not in a correct format

161 views
Skip to first unread message

Senor Cardgage

unread,
Sep 13, 2012, 6:11:14 PM9/13/12
to mongodb...@googlegroups.com
Using version 1.6
The following code results in a FormatException with message "Input string was not in a correct format"

var dataSet =
    from x in srv[db][coll].AsQueryable<BsonDocument>()
    where x["CustomerId"] == CustomerId                                           //CustomerId is an ObjectId
    orderby x["_id"]
    select x;

Why does the above try to convert "CustomerId" into an int on line 233 of BsonSerializationInfo.cs?

craiggwilson

unread,
Sep 13, 2012, 9:27:06 PM9/13/12
to mongodb...@googlegroups.com
Using a BsonDocument with linq is not supported at this time.  If you'd like this feature, please submit a feature request here:  https://jira.mongodb.org/browse/CSHARP.

craiggwilson

unread,
Sep 13, 2012, 9:29:04 PM9/13/12
to mongodb...@googlegroups.com
I might be wrong on that.  Could you post the complete stack trace and possibly a sample program that would let us reproduce the issue?

Robert Stam

unread,
Sep 13, 2012, 10:25:24 PM9/13/12
to mongodb...@googlegroups.com
I can confirm that the C# driver doesn't support LINQ queries against BsonDocument.

LINQ queries require a typed object to query against (at least as currently implemented).

There should definitely be a better error message though!

t1235...@gmail.com

unread,
Sep 6, 2013, 8:22:08 AM9/6/13
to mongodb...@googlegroups.com
Hi, as you see below - you can't use it directly

you can do though:

where Query.EQ("CustomerId"CustomerId).Inject()
Reply all
Reply to author
Forward
0 new messages