public static IEnumerable <T> CastDownEach <T, U, D>(this IBidirectional <U, D> bidirectional) { foreach (var up in bidirectional.DownList) { if (up is T t) { yield return(t); } } }
public static D DownNameFirstOrDefault <U, D>(this IBidirectional <U, D> relationShip, string name) where D : IBidirectional <U, D> { return(relationShip.DownList.FirstOrDefault(u => u.Name == name)); }
public static T CastDownFirstOrDefault <T, U, D>(this IBidirectional <U, D> bidirectional) where T : class where D : class { return(bidirectional.DownList.Where(d => d is T).Select(d => d as T).FirstOrDefault()); }
public static T CastUpFirstOrDefault <T, U, D>(this IBidirectional <U, D> bidirectional) where T : class where U : class { return(bidirectional.UpList.Where(u => u is T).Select(u => u as T).FirstOrDefault()); }