c# - List Grouping on multiple fields -
this question has answer here:
i have list of type contains 5 fields. list wish retrieve values groups issuetype & id together. in table below issuetype abc & id = 2 appears once in new list. how do this?
i should point out issuetype enumeration. not sure if makes difference
issuetype id abc 1 abc 2 abc 2 abc 3 xzy 4 xyz 1
i have tried using groupby in linq.
list<issuelog> uniqueerrorlog = errorlog.groupby(err => err.issuetype, err => err.id).select(err => err).tolist();
update
ok have since tried line below.
var uniqueerrorlog = errorlog.groupby(iss => new { iss.issuetype, iss.id });
i check output , grouping seems have made no difference. going table example can still see 2 abc's id = 2 being output when want one.
foreach (var issuetype in uniqueerrorlog) { foreach(var issue in issuetype) console.writeline(issue.issuetype + "," + issue.id); }
mylist.groupby(e => string.format("{0}_{1}", e.issuetype, e.id))
Comments
Post a Comment