1

I have a class with a property

  public List<Point> RouteWayPoints { get; set; }

Point - is a class of namespace System.Windows

When I Save this object into the Mongo Db - it works. But, when I try to get it from db with builders filter - i have an exception An error occurred while deserializing the RouteWayPoints property of class BusLaneRoutes: Value class System.Windows.Point cannot be deserialized.

    private IMongoCollection<BusLaneRoutes> _busLaneRoutesCollection;
    var filter = Builders<BusLaneRoutes>.Filter.Eq("RouteId", routeId);
    var result = _busLaneRoutesCollection.Find(filter).FirstOrDefault();

1 Answers1

0

The MongoDB C# driver doesn't support deserializing structs. Point is actually a struct, not a class. Therefore, you see this error.

There's an open bug requesting a fix for that, which hasn't been updated since 2014. There is a workaround though, as seen in this Stack Overflow answer, involving creating a custom serializer.

Community
  • 1
  • 1
Tomer
  • 1,606
  • 12
  • 18