-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.2.4
-
Environment:Windows
Hello. In c# driver version 2.0.1.-rc this is code was worked.
public class Person
{
public string Id
public string Name { get; set; }
}
public class SubObject
{
public Person Pers
public string SomeData { get; set; }
public SubObject(Person pers, string someData)
{ Pers = pers; SomeData = someData; }}
static void Main(string[] args)
{
MongoClient client = new MongoClient("mongodb://localhost");
var database = client.GetDatabase("TestDataBase");
var objectsCollection = database.GetCollection<Person>("TestCollection");
objectsCollection.Database.DropCollection(objectsCollection.CollectionNamespace.CollectionName);
var person = new Person()
{ Id = "12", Name = "Alex" };
objectsCollection.InsertOne(person);
person = new Person()
;
objectsCollection.InsertOne(person);
var result1 = objectsCollection.AsQueryable().Where(o => o.Name.Length > 4).ToList(); // return 1 object
var result2 = objectsCollection.AsQueryable().Where(o => o.Name.Length > 4).Select(o => new SubObject(o, "test text")).ToList();
} // this code worked in 2.0.1-rc, but don't work in 2.2.4
This is bug or not?
- duplicates
-
CSHARP-3922 LINQ3: support calls to constructors in Select
- Closed
- is duplicated by
-
CSHARP-1963 Select with create new object not supported
- Closed