-
Type:
Bug
-
Status: Closed
-
Priority:
Major - P3
-
Resolution: Fixed
-
Affects Version/s: 2.0
-
Fix Version/s: 2.0
-
Component/s: None
-
Labels:None
The below test should pass, but doesn't because it treats the predicate as an IEntity, not as a MyEntity.
[TestFixture]
|
public class InterfaceSample
|
{
|
[Test]
|
public async Task Test()
|
{
|
var subject = DriverTestConfiguration.Client.GetDatabase("test").GetCollection<MyEntity>("test");
|
await subject.DeleteManyAsync("{}");
|
await subject.InsertOneAsync(new MyEntity { Id = 3, Type = "awesome" });
|
|
var entity = await Find(subject, 3);
|
}
|
|
private Task<T> Find<T>(IMongoCollection<T> collection, int id) where T : IEntity
|
{
|
return collection.Find(x => x.Id == id).FirstOrDefaultAsync();
|
}
|
}
|
|
public interface IEntity
|
{
|
int Id { get; set; }
|
}
|
|
public class MyEntity : IEntity
|
{
|
public int Id { get; set; }
|
|
public string Type { get; set; }
|
}
|