I could not find any similar example. In my DB I have a column of string[] array, where they are divided with comma. Example of 3 rows:
id1: apple, orange, banana, kiwi
id2: orange, kiwi
id3: lemon, pineaple, kiwi
From this list I need to extract with LINQ a List of distinct strings: apple, orange, banana, kiwi, lemon, pineapple.
I managed to do it, but not purely LINQ, but when using also foreach:
public async Task<List<string>> GetFruitDetailedType()
{
List<string> all = new List<string>();
var qry = await GetFruitsQueryable().Select(v => v.DetailedType).ToListAsync();
foreach (var item in qry)
{
foreach(var type in item)
{
all.Add(type);
}
}
return (from w in all select w).Distinct().ToList();
}
Is there a way to do it just with LINQ, without calling for object with all entities?
NOTE: using EF Core 2.
SelectManyto flat map a list of lists.