/// <summary> /// Carry out final validation after all the property configurations (default, convention, user) have been applied. /// </summary> protected virtual void ValidateFinal() { IEnumerable <TPropertyConfiguration> primaryIdentifiers = PropertyConfigurations.Where(prop => prop.IsPrimaryResourceIdentifier); ExceptionHelper.InvalidOperation.ThrowIfTrue( primaryIdentifiers.Count() != 1, $"There must be exactly of 1 property marked as the primary identifier for {typeof(TResource).Name}. " + $"Currently: {string.Join(", ", primaryIdentifiers.Select(x => x.PropertyName))}"); ExceptionHelper.InvalidOperation.ThrowIfTrue( primaryIdentifiers.First().HasComputedValue&& primaryIdentifiers.First().ValueComputationFunc.EndpointTriggers.HasFlag(HttpVerbs.PUT), $"The primary identifier for {typeof(TResource).Name} must not be updatable via PUT."); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual List <PropertyConfiguration> GetPropertyConfigurations(bool useFluentApiOnly) { return(PropertyConfigurations .Where(pc => pc.GetFluentApiConfigurations(useFluentApiOnly).Any()).ToList()); }