The database I'm working in stores a pair of double values in two integer columns.
The IOW department is double with values such as 42.12, but is stored in the Dept column (which in this case is 42) and the Subdept column (which in this case contains 12). Do not ask me why (because you will be disappointed, I cannot tell you why, because I do not know).
I need to get a subset of data such as "all department records between 8.79 and 98.87"
I have this code:
public IEnumerable<InventoryItem> GetDepartmentRange(double deptBegin, double deptEnd, string dbContext)
{
LoadInventoryItems(dbContext);
var deptStartWhole = (int)Math.Truncate(deptBegin);
var startFraction = (int)((deptBegin - deptStartWhole) * 100);
var deptEndWhole = (int)Math.Truncate(deptEnd);
var 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)
.OrderBy(o => o.dept)
.ThenBy(s => s.subdept);
}
... but it didn’t quite work - with the above query (Depts between 8.79 and 98.87) it shows deblocks that are 98.88, which is one of what I want.
, ( ).
, "" , , .
UPDATE
