I need some help filtering a SQL WIQL query. How can I modify the code below to ignore the fields that have empty model values? For example if the user only wants to filter one field like the work item type and ignore the state field? Any help would be appreciated.
public async Task<ActionResult> Method(filterModel model)
{
VssConnection connection = new VssConnection(new
Uri(vstsCollectionUrl), new VssClientCredentials());
WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();
Wiql query = new Wiql() { Query = "SELECT [Id], [Title] FROM workitems WHERE [Work Item Type] = '" + model.workitem + "' &&
[State] = '"+ model.state + "'"};
WorkItemQueryResult queryResults = witClient.QueryByWiqlAsync(query).Result;
if (queryResults == null || queryResults.WorkItems.Count() == 0)
{
Console.WriteLine("Query did not find any results");
}
}