Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for BsonDocuments as values, allowing nested documents #47

Merged
merged 1 commit into from
Nov 14, 2016

Conversation

Innogator
Copy link
Contributor

@Innogator Innogator commented Oct 22, 2016

BsonValue supports primitive types and ends up converting values to strings. This leads to complex objects being represented within a single value as a string. If the passed in value is a more complex object, convert it to a BsonDocument.

Addresses Issue #38

…e complex object, convert it to a BsonDocument
@emadb
Copy link
Collaborator

emadb commented Oct 24, 2016

Ok for me.

// if the object is complex and can't be mapped to a simple object, convert to bson document
if (!BsonTypeMapper.TryMapToBsonValue(value, out bsonValue))
{
bsonValue = value.ToBsonDocument();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the ToBsonDocument() call redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so, since we need a BsonValue type to pass in to the doc.Add() function and an object type doesn't fulfill that. The BsonDocument type is a subclass of BsonValue and so is more specific. Or maybe I'm missing your point all together?

@Innogator
Copy link
Contributor Author

Any other opinions on this PR? This seems to be a wanted feature from users and it would be convenient to be able to use the .nuget package instead of having a copy of the source locally.

@emadb emadb merged commit 4df2dfe into log4mongo:master Nov 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants