Details
-
Bug
-
Resolution: Unresolved
-
Unknown
-
None
-
2.12.4
-
None
-
None
Description
i'm trying to project to a different type inside the facet pipeline as shown below. everything works fine if i comment out the `CamelCaseElementNameConvention`.
but throws `System.FormatException: 'Element 'AuthorName' does not match any field or property of class TestApplication.Program+AuthorDTO.'` if the convention is registered.
here's a small repro:
public class Author |
{
|
public string FullName { get; set; } |
}
|
public class AuthorDTO |
{
|
public string AuthorName { get; set; } |
}
|
ConventionRegistry.Register(
|
name: "CustomConventionPack", |
conventions: new ConventionPack { new CamelCaseElementNameConvention() }, |
filter: _ => true); |
|
|
var collection = new MongoClient("mongodb://localhost").GetDatabase("test").GetCollection<Author>("Author"); |
|
|
await collection.Database.DropCollectionAsync("Author"); |
|
|
await collection.InsertOneAsync(new Author { FullName = "author name" }); |
|
|
var projectStage = PipelineStageDefinitionBuilder.Project<Author, AuthorDTO>(
|
a => new AuthorDTO |
{
|
AuthorName = a.FullName
|
});
|
|
|
var resultsFacet = AggregateFacet.Create<Author, AuthorDTO>("_results", new[] { projectStage }); |
|
|
var res = await collection
|
.Aggregate()
|
//.AppendStage(projectStage) |
.Facet(resultsFacet)
|
.ToListAsync();
|
|
|
var authorName = res[0].Facets[0].Output<AuthorDTO>()[0].AuthorName; |
it even works fine with `.AppendState()` and the problem only occurs with `.Facet()`