-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Fully Compatible
-
Dotnet Drivers
-
Not Needed
-
-
None
-
None
-
None
-
None
-
None
-
None
Issue:
When trying to use .Select() where the lambda body is a new Dictionary<string,object> or new BsonDocument, the following error is observed:
System.InvalidOperationException When called from 'VisitListInit', rewriting a node of type 'System.Linq.Expressions.NewExpression' must return a non-null value of the same type. Alternatively, override 'VisitListInit' and change it to not visit children of this type.
The original Visit() call occurs in PartialEvaluator.cs.
Repro:
[Fact]
public void Select_Bson_objField_should_work()
{
var collection = GetCollection(LinqProvider.V3);
var queryable = collection.AsQueryable()
.Select(x => new BsonDocument
{
{ "a", x.A }
});
var stages = Translate(collection, queryable);
var dt = queryable.ToList();
}
[Fact]
public void Select_Dict_obj_should_work()
{
var collection = GetCollection(LinqProvider.V3);
var queryable = collection.AsQueryable()
.Select(x => new Dictionary<string, object>
{
{ "a", x }
});
var stages = Translate(collection, queryable);
var dt = queryable.ToList();
}
private class C
{
public int A { get; set; }
}
- is depended on by
-
ODATA-29 Implement execution of calculations on database level for SelectSome
-
- Closed
-
- related to
-
CSHARP-5198 Support Select new Dictionary<string, object>
-
- Backlog
-