我想知道如何从业务逻辑层调用uri方法。这是我到目前为止,我得到的编译器错误很少。如果有人可以指导正确的方法/框架来构建以下内容:
数据类:
public Results GetData(Query query)
{
var data = db.database.AsQueryable();
if (query.name != null)
{
data = data.Where(c => c.Name == query.name);
}
if (query.cusip != null)
{
data = data.Where(c => c.CUSIP == query.cusip);
}
if (!data.Any())
{
return data.AsQueryable();
}
}
Data api controller:
public HttpResponseMessage GetMulti([FromUri]Query query)
{
Data layer = new Data();
var result = layer.GetData(query);
var message = string.Format("No data was found");
return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
}