我需要一些帮助来过滤SQL WIQL 查询。如何修改下面的代码以忽略具有空模型值的字段?例如,如果用户只想过滤一个像工作项类型这样的字段而忽略状态字段?任何帮助,将不胜感激。
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");
}
}