protected virtual Func<PomonaContext, PomonaResponse> ResolveGetCollectionProperty(ResourcePropertyRoute route, ResourceProperty property, ResourceType resourceItemType) { if (this.capabilityResolver.PropertyIsMapped(property.PropertyInfo) || property.GetPropertyFormula() != null) { return pr => { // Check existance of parent here, cannot differentiate between an empty collection and not found. var parent = pr.Node.Parent; if (parent.Route.IsSingle) { if (!parent.Exists) throw new ResourceNotFoundException("Resource not found."); } return new PomonaResponse( parent .Query() .OfTypeIfRequired(pr.Node.Route.InputType) .SelectManyEx(x => x.Apply(property.CreateGetterExpression)) .WrapActionResult(defaultPageSize : property.ExposedAsRepository ? (int?)null : int.MaxValue)); }; } else { return pr => { var parentNode = pr.Node.Parent; if (parentNode.Route.IsSingle) return new PomonaResponse(((IEnumerable)property.GetValue(parentNode.Get())).AsQueryable()); return new PomonaResponse( pr.Node.Parent .Query() .OfTypeIfRequired(pr.Node.Route.InputType) .ToListDetectType() .AsQueryable() .SelectManyEx(x => x.Apply(property.CreateGetterExpression)) .WrapActionResult(defaultPageSize : property.ExposedAsRepository ? (int?)null : int.MaxValue)); }; } }
public ResourcePropertyRoute(ResourceProperty property, Route parent) : base(0, parent) { Property = property; }
public override ResourcePropertyDetails LoadResourcePropertyDetails(ResourceProperty property) { var propInfo = property.PropertyInfo; return new ResourcePropertyDetails(Filter.ClientPropertyIsExposedAsRepository(propInfo), NameUtils.ConvertCamelCaseToUri(Filter.GetPropertyMappedName(property.ReflectedType, propInfo))); }
public abstract ResourcePropertyDetails LoadResourcePropertyDetails(ResourceProperty property);