I am trying to pass a Lambda Expression to a Web API 2 call and not sure how to make this work.
Let me give you some background
Setup a Web API 2 that utilizes Entity Framework to communicate to the Database.
My applications ultimately call up to the Web API 2 to be able to communicate with the Database. My company ultimately requires this to allow added security to the Data Access Layer.
We have built a repository on the App Side that communicates with the Web API just fine. However one of the functions we want to add is a FIND function that incorporates a Lambda Expression.
public IEnumerable<T> FindAll(Func<T, bool> exp)
{
HttpClientHandler hndlr = new HttpClientHandler();
hndlr.UseDefaultCredentials = true;
HttpClient httpClient = new HttpClient(hndlr);
httpClient.BaseAddress = new Uri(ADMS.Utilities.Settings.DALService);
HttpResponseMessage response = httpClient.GetAsync(string.Format("api/{0}/{1}", typeof(T).Name, exp)).Result;
if (response.IsSuccessStatusCode)
{
return response.Content.ReadAsAsync<IEnumerable<T>>().Result.ToList();
}
return null;
}
Question I have is now on the Web API 2 side in the controller how do I get this to accept the Lambda Expression? What do I need to put in the controller to see this? Do I need to convert the Lambda Expression?