我有一个Web API方法,需要两个双参数:
存储库界面:
public interface IInventoryItemRepository
{
. . .
IEnumerable<InventoryItem> GetDepartmentRange(double deptBegin, double deptEnd);
. . .
}
Run Code Online (Sandbox Code Playgroud)
库:
public IEnumerable<InventoryItem> GetDepartmentRange(double deptBegin, double deptEnd)
{
// Break the doubles into their component parts:
int deptStartWhole = (int)Math.Truncate(deptBegin);
int startFraction = (int)((deptBegin - deptStartWhole) * 100);
int deptEndWhole = (int)Math.Truncate(deptEnd);
int endFraction = (int)((deptBegin - deptEndWhole) * 100);
return inventoryItems.Where(d => d.dept >= deptStartWhole).Where(e => e.subdept >= startFraction)
.Where(f => f.dept <= deptEndWhole).Where(g => g.subdept >= endFraction);
}
Run Code Online (Sandbox Code Playgroud)
控制器: …