Client filtering, strongly typed

Hi All,

I have a .NET client that calls an AutoQuery endpoint in our REST API. I would like the client to have the ability to filter the results based on (strongly typed) dto properties. Example:

I have a dto thus:

public partial class BO_Priority : IHasId<string> 
    public string Id { get; set; }
    public string PriorityDescription { get; set; }
    public int PriorityWeight { get; set; }

The BO_Priority table contains some data:

1   Low    50
2   SLA Med  50
3   SLA High  100

I have an endpoint and associated functions in the REST API:

AppHost.Routes.Add(typeof(FindBackorderPriority),"/backorder/priority/find", "GET", "Retreives a list of backorder priorities.", "");

public class FindBackorderPriority : QueryDb<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.BO_Priority>

public class BackorderServices : Service
	public IAutoQueryDb AutoQuery { get; set; }

	public object Get(FindBackorderPriority query)
		var q = AutoQuery.CreateQuery(query, base.Request);

		return AutoQuery.Execute(query, q);

My .NET client can make a call like this:

var backorderPriorities = client.Get(new FindBackorderPriority());

and receive all three records. How can my client make a call, but specify that it only wants records where the “PriorityDescription” field contains the the text “SLA”?

Any tips will be appreciated,


Your AutoQuery Service should contain the queries you want available so if you want them to be able to query by PriorityDescription containing specified text you can just add it to your Request DTO, e.g:

public class FindBackorderPriority : QueryDb<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.BO_Priority>
    public string PriorityDescriptionContains { get; set; }

Which your client can call with:

var backorderPriorities = client.Get(new FindBackorderPriority { 
    PriorityDescriptionContains = "SLA"

This works since Contains is an implicit convention.