I think you want to use Select
here instead of SelectMany
.
SelectMany
is used to select a collection in the object you are handling in your query. The selected collections are then joined together in the result.
For example if you got something like this:
var a = {Tuple.Create("a", {1, 2, 3}),
Tuple.Create("b", {4, 5, 6}),
Tuple.Create("c", {7, 8, 9})}
You could use SelectMany
to get all the result values in Item2
of the Tuple
joined in one list. a.SelectMany(t => t.Item2)
would result in
{1, 2, 3, 4, 5, 6, 7, 8, 9}
Select on the other hand is used to mark exactly one result (and I assume that this is what you want. So a.Select(t => t.Item1)
would result in {"a", "b", "c"}
and a.Select(t => t.Item2)
would result in:
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
So all in all I think in your case something like
MyRepeater.DataSource = Objects.GroupBy(p => p.FAC_ID).Select(p => p.First())
.First().Dipartimento.AreeDipartimento
.Select(p => p.Aree);
would be correct. This is all the tips I can give you without additional information regarding your data structure and your expected results.