You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.
So I'm just trying this out for the first time and I noticed that types like Guid and DateTimeOffset were getting serialized as binary blobs and/or byte arrays. Is that normal? I would have thought they would have called ToString() before storing or something.
The text was updated successfully, but these errors were encountered:
You can use an attribute (for example: a BsonDateTimeOptions attribute) to change the serializiation to your needs (in this example the attribute can be used to specify you would only want to serialize the date-'part' for example and ignore the time-'part'). This is not something MongoRepository provides but is provided by the underlying mongo-csharp-driver. You can find documentation here. You can also use conventions (see here) which are, again, something provided by the underlying mongo-csharp-driver.
I would, however, advice to use the 'binary blob' unless you have a very specific and good reason to want to serialize to string.
classMyObject:Entity{publicGuidSomeProperty{get;set;}}varmyrepo=newMongoRepository<MyObject>();varsomeguid=Guid.NewGuid();varx=newMyObject{SomeProperty=someguid};// Save objectmyrepo.Update(x);
You can simply query it like this:
myrepo.Where(o =>o.SomeProperty==someguid);
(Code written on the fly; may contain some (syntax)errors).
If you want to query it from other platforms you can query it with something like:
So I'm just trying this out for the first time and I noticed that types like Guid and DateTimeOffset were getting serialized as binary blobs and/or byte arrays. Is that normal? I would have thought they would have called ToString() before storing or something.
The text was updated successfully, but these errors were encountered: