I have a predicate builder that accepts a SearchInfo Class. For most cases this works great, but has problems if a user specifies a query on a property that has a deep object graph. For example, a list of possible properties:
var names = new[] { "Action.Strategy.Objective.Goal.Identifier", "Action.Strategy.Objective.Identifier", "Action.Strategy.Identifier", "Action.Identifier" };
So how do I go about building the predicate that my predicate builder can understand when I have a deep object graph? My predicate builder is a combination of this and this. This all needs to be performed at run-time as the actual objects being queried can change based on user input. In essence a dynamic LINQ query builder of sorts.
SearchInfo.Comparer is of type Expression>
The Directive:
public class Directive : EntityWithTypedId<Guid>, INamedEntity
{
[NotNull(Message = "Directive name required")]
public virtual string Name { get; set; }
public virtual string Description { get; set; }
public virtual DirectiveStatus DirectiveStatus { get; set; }
public virtual DirectiveType DirectiveType { get; set; }
public virtual String Tags { get; set; }
public virtual User Manager { get; set; }
public virtual User Technician { get; set; }
public virtual PerformanceMeasurementPlan PerformancePlan { get; set; }
public virtual Action Action { get; set; }
public virtual Department Department { get; set; }
public virtual IList<Measure> Measures { get; set; }
public virtual Sip Sip { get; set; }
public virtual string SipId
{
get
{
return String.Format(
"{0}.{1}.{2}.{3}",
Action.Strategy.Objective.Goal.Identifier,
Action.Strategy.Objective.Identifier,
Action.Strategy.Identifier,
Action.Identifier);
}
}
}