There are several ways to do this; I used a combination of API criteria and query objects. For example, if you have a collection of persons that you want to request:
1) More flexible API criteria method: GetPerson (IList request)
public class Criteria { Object Property; // (Domain property, not DB)// (String Or Lambda) Age, Father.Age, Friends, etc Object Operator; //(Enum or String)(Eq, Gr, Between,Contains, StartWith, Whatever...) Object Value; // (most likely Object, or use generics Criteria<T>), (Guid, int[], Person, any type). }
2) The strictly described request object:
public class PersonQuery { Guid? Id; GenderEnum? Gender; Int32? Age; Int32? AgeMin; Int32? AgeMax; String Name; String NameContains; Person FatherIs; Person MotherIs;
Use Nullable <> for Value types and assign Null to indicate that the parameter is not required.
Each method has positive and negative sides.
source share