This request is regarding `MongoDB.Bson`.
I have an API controller that looks like this:
```csharp
// ...
public class MyController : Microsoft.AspNetCore.Mvc.ControllerBase
// ...
[HttpGet(nameof(GetData))]
public async Task<IActionResult> GetData(CancellationToken ct)
{
var memoryStream = new MemoryStream();
BsonSerializer.Serialize(new BsonBinaryWriter(memoryStream), <INSTANCE_OF_A_CLASS>);
Response.ContentType = MediaTypeNames.Application.Octet;
await Response.Body.WriteAsync(memoryStream.GetBuffer().AsMemory(0, (int)memoryStream.Length), ct);
return Empty;
}
// ...
```
The problem is that there is no way to serialize one way for data going to the database,
and another way for data going to the client,
because there is no way to supply a custom `_conventionPack` to class `BsonClassMap`,
and of course no way to pass it at the serialize call site.
I discovered this when trying to serialize a class with an `Id` property.
The `Id` property becomes `_id` for the database which is ok.
But it is also `_id` for the client which I do not want.
I wish to also customize other aspects like casing.
At the serialize call site, I want to selectively add `NoIdMemberConvention` or remove `NamedIdMemberConvention`.
A workaround right now might look something like:
Replacing the `__defaults__` `ConventionPackContainer` in `ConventionRegistry`
with my own that filters out [1] an empty class type which extends my actual class.
What's your peoples take on this?
Should I just use `Newtonsoft.Json.Bson`? Is this package for serializing to the database only?
[1] MongoDB.Bson.Serialization.Conventions.ConventionRegistry.ConventionPackContainer.Filter