I have a generic list of SharePoint list items (List employees)
The SharePoint list contains the two columns, "Employee Name" and "Employee Designation"
I want to get an object List which contains distinct "Employee Designation" column values.
How do I do this using LINQ?
This didnt work for me:
var designations = from SPListItem employee in employees
select new {Designation = employee["Employee Designation"].ToString().Distinct()};
If you are only retrieving the string value of that column, you can avoid writing an equality comparer by selecting a string (instead of an object containing a string property).
var designations = (from SPListItem employee in employees
select employee["Employee Designation"].ToString())
.Distinct()
.ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With