Table of Contents

Class ODataMetadataOptions

Namespace
Utils.OData
Assembly
Utils.OData.dll

Configures how EDMX metadata is loaded by ODataContext, providing a single, consistent policy for the maximum accepted size, the transport used for remote downloads, the download timeout, and the cross-host redirect behaviour.

public sealed class ODataMetadataOptions
Inheritance
ODataMetadataOptions
Inherited Members
Extension Methods

Remarks

This type addresses several audit findings for ODataContext: injectable/reusable HttpClient (item 16), a consistent bounded size policy across every metadata source (items 15 and 33), cancellation and dependency injection (items 14 and 29), and an explicit redirect destination policy (item 30).

Fields

DefaultMaxMetadataBytes

The default maximum accepted size, in bytes, for EDMX metadata (10 MiB).

public const int DefaultMaxMetadataBytes = 10485760

Field Value

int

Properties

AllowCrossOriginRedirect

Gets or sets a value indicating whether the metadata download may follow a redirect to a different origin (scheme, host, or port). Defaults to false, so a trusted metadata URL that is redirected to another origin is rejected before the second request is sent (item 30).

public bool AllowCrossOriginRedirect { get; init; }

Property Value

bool

Remarks

When false (the default), the library follows redirects manually so that the destination is validated before any request is sent to it. This prevention is guaranteed for the built-in shared client. For a caller-supplied HttpClient whose handler has AllowAutoRedirect = true, the library performs a best-effort post-hoc check on the final request URI; callers that need strict prevention must configure their handler with AllowAutoRedirect = false.

Default

Gets a shared, immutable default configuration: a 10 MiB size cap, a 30-second download timeout, no injected client, and cross-host redirects disallowed.

public static ODataMetadataOptions Default { get; }

Property Value

ODataMetadataOptions

DownloadTimeout

Gets or sets the timeout applied to remote metadata downloads. Defaults to 30 seconds.

public TimeSpan DownloadTimeout { get; init; }

Property Value

TimeSpan

HttpClient

Gets or sets the HttpClient used to download remote metadata. When null, a shared internal client is reused so that a new client is not created per download (item 16). The caller owns and is responsible for disposing any injected client.

public HttpClient? HttpClient { get; init; }

Property Value

HttpClient

MaxMetadataBytes

Gets or sets the maximum accepted size, in bytes, for EDMX metadata from any source. Defaults to DefaultMaxMetadataBytes.

public int MaxMetadataBytes { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

Thrown when set to a non-positive value.

MaxRedirects

Gets or sets the maximum number of HTTP redirects that the library will follow when loading remote metadata. Defaults to 10.

public int MaxRedirects { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

Thrown when set to a negative value.