Reputation: 6572
I tried both of this but didn't work? how to do that?
.SelectMany(x => x.SectionEvents).SelectMany(t => t.Section)
.SelectMany(x => x.SectionEvents.SelectMany(t => t.Section))
Error :
The type arguments for method '
System.Linq.Enumerable.SelectMany<TSource,TResult>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,System.Collections.Generic.IEnumerable<TResult>>)
' cannot be inferred from the usage. Try specifying the type arguments explicitly.
EEvent.List<EEvent>("CalendarPeriodUId", ECalendarPeriod.Current().UId).Value.ToList()
.SelectMany(x => x.SectionEvents.SelectMany(t => t.Section)).ToFCollection().Bind(ddlSection, "SectionName");
Upvotes: 0
Views: 1048
Reputation: 14640
I think you want is to select all Sections from Events through a join table.
public class Event
{
public ICollection<SectionEvent> SectionEvents { get; set; }
}
public class SectionEvent
{
public Event Event { get; set; }
public Section Section { get; set; }
}
public class Section
{
public ICollection<SectionEvent> SectionEvents { get; set; }
}
If that so, then what you need is SelectMany
and Select
.
var q = events.SelectMany(e => e.SectionEvents).Select(se => se.Section);
Upvotes: 2