-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: 2.17.1
-
Component/s: None
-
None
-
Fully Compatible
the following exception is being thrown by linq v3 if a simple join query is performed within a generic method:
> System.ArgumentException: 'Invalid toType: IEntity. (Parameter 'toType')'
here's how to reproduce it:
the classes
public interface IEntity { string Id { get; set; } } public class Parent : IEntity { [BsonId] public string Id { get; set; } [BsonRepresentation(BsonType.ObjectId)] public string ChildId { get; set; } } public class Child : IEntity { [BsonId] public string Id { get; set; } }
the program
var children = GetChildrenQueryable<Child>(db, "Child"); children.Count(); private IMongoQueryable<TChild> GetChildrenQueryable<TChild>(IMongoDatabase db, string childCollectionName) where TChild : IEntity { var parentCollection = db.GetCollection<Parent>("Parent"); var childCollection = db.GetCollection<TChild>(childCollectionName).AsQueryable(); return parentCollection .AsQueryable() .Join( childCollection, p => p.ChildId, c => c.Id, (_, c) => c); }
this works perfectly fine with line v2.
would highly appreciate a workaround until this can be fixed.
thanks!