/// <summary> /// Traverses through the provided entity and returns the /// value of the relationship on the other side of a join entity /// (e.g. Articles.ArticleTags.Tag). /// </summary> public override object GetValue(object entity) { IEnumerable joinEntities = (IEnumerable)ThroughProperty.GetValue(entity) ?? Array.Empty <object>(); IEnumerable <object> rightEntities = joinEntities .Cast <object>() .Select(rightEntity => RightProperty.GetValue(rightEntity)); return(rightEntities.CopyToTypedCollection(PropertyInfo.PropertyType)); }
/// <summary> /// Traverses through the provided resource and returns the value of the relationship on the other side of the through type. In the example described /// above, this would be the value of "Articles.ArticleTags.Tag". /// </summary> public override object GetValue(object resource) { ArgumentGuard.NotNull(resource, nameof(resource)); object throughEntity = ThroughProperty.GetValue(resource); if (throughEntity == null) { return(null); } IEnumerable <object> rightResources = ((IEnumerable)throughEntity).Cast <object>().Select(rightResource => RightProperty.GetValue(rightResource)); return(CollectionConverter.CopyToTypedCollection(rightResources, Property.PropertyType)); }
/// <summary> /// Traverses through the provided resource and returns the value of the relationship on the other side of the through type. /// In the example described above, this would be the value of "Articles.ArticleTags.Tag". /// </summary> public override object GetValue(object resource) { if (resource == null) { throw new ArgumentNullException(nameof(resource)); } var throughEntity = ThroughProperty.GetValue(resource); if (throughEntity == null) { return(null); } IEnumerable <object> rightResources = ((IEnumerable)throughEntity) .Cast <object>() .Select(rightResource => RightProperty.GetValue(rightResource)); return(TypeHelper.CopyToTypedCollection(rightResources, Property.PropertyType)); }