public interface IQueryOption
{
IQueryOption FilterBy(Expression<Func<Contact, bool>> filter);
IQueryOption AddEagerLoad(Expression<Func<Contact, object>> eagerLoad);
}
public class QueryOption : IQueryOption
{
internal List<Expression<Func<Contact, object>>> EagerLoads { get; set; }
internal Expression<Func<Contact, bool>> Filter { get; set; }
public IQueryOption FilterBy(Expression<Func<Contact, bool>> filter)
{
Filter = filter;
return this;
}
public IQueryOption AddEagerLoad(Expression<Func<Contact, object>> eagerLoad)
{
if(EagerLoads == null)
EagerLoads = new List<Expression<Func<Contact, object>>>();
EagerLoads.Add(eagerLoad);
return this;
}
}