2👍
You need to assign result of GroupBy() to variable:
returnList = returnList.GroupBy(rec => rec.PropertyAddress).ToList();
2👍
Make sure to actually use the new IEnumerable that the .GroupBy()
Method returned.
If you want to return a List you need to use a workaround:
- Get the
IEnumerable<IGrouping<int, ReturnRecord>>
from the.GroupBy()
- Use
.SelectMany()
to select all elements and save them into an IEnumerable - Now you can convert your IEnumerable into a List with
.List()
Example:
// Longer Alternative
IEnumerable<IGrouping<int, ReturnRecord>> groups = resultList
.GroupBy((rec => rec.PropertyAddress);
IEnumerable<ReturnRecord> result = groups.SelectMany(group => group);
List<ReturnRecord> listResult = result.ToList();
return Ok(listResult);
// Shorter Alternative
IEnumerable<IGrouping<int, ReturnRecord>> groups = resultList
.GroupBy((rec => rec.PropertyAddress);
IEnumerable<ReturnRecord> result = groups.SelectMany(group => group);
return Ok(result.ToList());
- [Vuejs]-Not able to retrieve data from JSON object in Vue
- [Vuejs]-How to input text Value renders as html entity in Vue. some stuffs i check and not solved area
Source:stackexchange.com