How can i make out
Expression<Func<T, bool>> predicate
to
Expression<Func<SomeType, bool>> predicate
?
So far, no way to find a way. Or at least create a new Expression<Func<SomeType, bool>> using the first string representation of the predicate.
If this helps, T limited to the implementation type of ISomeInterface , and SomeType implements it.
LE: further clarification
The interface looks something like this:
public interface ICacheable { List<T> GetObjects<T>(Expression<Func<T, bool>> predicate) where T : ICacheable; }
then you have
public partial class Video : ICacheable { public List<T> GetObjects<T>(Expression<Func<T, bool>> predicate) where T : ICacheable {
then you have:
public class RedisCache { public List<T> GetList<T>(Expression<Func<T, bool>> predicate) where T : ICacheable { List<T> objList =
I use the above from any class as follows:
// If the list is not found, the cache store automatically retrieves // and caches the data based on the methods enforced by the interface // The overall structure and logic has more to it. List<Video> videos = redisCache.GetList<Video>(v => v.Title.Contains("some text")); List<Image> images = redisCache.GetList<Image>(v => v.Title.Contains("another text"));
And I would extend this to any type of object that I need to cache, with methods that allow the Cache repository to automatically get an object or a list of objects if they are not found in the cache. I could do it completely wrong though.