MongoDB C# 2 Driver -- Cannot deserialize 'String' from BsonType 'Double' -
i new mongodb. trying retrieve entries in lookup collection. receiving following error:
{"an error occurred while deserializing symbol property of class stock.models.stocklookup: cannot deserialize 'string' bsontype 'double'."}
this code receiving error on:
var stocklookups = _stocklookuprepository.getallasync().result.orderby(l => l.symbol);
here method being called:
public async task<list<stocklookup>> getallasync() { var result = await _collection.find(sl => sl.symbol != null).tolistasync(); return result; }
here stocklookup class:
public class stocklookup { public objectid id { get; set; } public string symbol { get; set; } public string name { get; set; } }
can me figure out problem is? appreciated.
thanks!
the message explained itself. defined symbol
string
, while in database there's document has double
type symbol
. it's causing deserializing issue. find out these illegal data, try:
db.stocklookup.find({symbol: {$type: 1}}
don't if have big amount of data in collection. there's no index on , it's going slow. in case may want add other conditions filter out data before checking type.
there reference of $types. may want check how these data goes collection otherwise there more illegal data.
Comments
Post a Comment