I have a SharePoint list containing some items. I would like to apply grouping to the items using LINQ, preferably with
This is the list of fields that the list item is consisted of:
- Title - Single line of text field
- Date - Date and time field
- Related - Lookup field
I need to have the items collection grouped by the
Related lookup field. I am unable to figure out what to specify for
GroupBy method parameters. The following code throws an error and prevents it being built.
var items = list.Items; var groupedItems = items.Cast<SPListItem>(). GroupBy(item => new SPFieldLookupValue(item["Related"].ToString()).LookupId);
Replacing LINQ with
<GroupBy> element in list item query is not an option.