Ok, aside from the silly title. I have a query pulling back distinct values but it is including the departmentID
column instead of the departmentName
column as distinct. Which makes me sometimes causes duplicates.
ViewBag.DepartmentList = docs.Select(m => new SelectListItem
{
Value = SqlFunctions.StringConvert((double)m.departmentID).Trim(),
Text = m.departmentName
})
.Distinct(); // Fill the viewbag with a unique list of 'Department's from the table.
Here is what the docs has inside it:
If it helps at all, the departmentID
is a primary key. so departmentID 1
will always point to the same name and so on.