To explain my problem here a short example:
public interface IData
{
Guid Id { get; }
DateTime Time { get; }
}
public interface IProvider
{
IEnumerable<IData> GetObjects(Expression<Func<IData,bool>> expr);
}
public class MyData : IData { ... }
public class MyProvider : IProvider
{
IEnumerable<IData> GetObjects(Expression<Func<IData,bool>> expr)
{
// !!! This part is my problem:
// I need to convert the Expression, defined on the Interface
// to the actual implemented class.
return GetObjectsSpecific(expr); // Does not work!!!
}
IEnumerable<MyData> GetObjectsSpecific(Expression<Func<MyData,bool>> expr)
{
// Already fully implemented und functional
}
}
public class Program
{
public void Test()
{
IProvider prov = new MyProvider();
var objects = prov.GetObjects(data => data.Time < DateTime.Now);
}
}
So the question is: Can the expression, defined on the common interface, be transformed(?) so that it uses the actual class, which implements the common interface?
Any ideas?