Support expressions like:
queryable().Select(_ => new KeyValuePair(...))
Note: after investigation I'm modifying the description of this ticket to make it more general to refer to the use of any constructor call in Select statement. The current implementation assumes that any `NewExpression` is the creation of an anonymous type value, but that's not always true.
The following test case illustrates a simple case of the more general problem to be solved:
[Fact] public void Select_with_constructor_call_should_work() { var client = DriverTestConfiguration.Linq3Client; var database = client.GetDatabase("test"); var collection = database.GetCollection<C>("test"); var queryable = collection.AsQueryable() .Select(c => new D(c.X)); var stages = Linq3TestHelpers.Translate(collection, queryable); var expectedStages = new[] { "{ $project : { Y : '$X', _id : 0 } }" }; Linq3TestHelpers.AssertStages(stages, expectedStages); } private class C { public int Id { get; set; } public int X { get; set; } } private class D { public D(int y) { Y = y; } public int Y { get; set; } }
- is depended on by
-
CSHARP-3923 Improve exception message when using structs without custom serializers in linq expressions
- Closed
-
CSHARP-3924 Support Tuples in LINQ3
- Closed
- is duplicated by
-
CSHARP-1691 Select with create new object throw exception
- Closed
-
CSHARP-4180 Correct handling NewExpression.Members when null
- Closed