Skip to main content

Definition

Assembly: Microsoft.OData.Mcp.Core.dll Namespace: Microsoft.OData.Mcp.Core.Models Inheritance: System.Object

Syntax

Microsoft.OData.Mcp.Core.Models.EdmSingleton

Summary

Represents a singleton in an OData entity container.

Remarks

Singletons represent individual entity instances that are addressable as single resources rather than collections. They are useful for representing unique entities like service configuration, user profiles, or system settings that exist as single instances.

Constructors

.ctor

Initializes a new instance of the EdmSingleton class.

Syntax

public EdmSingleton()

.ctor

Initializes a new instance of the EdmSingleton class with the specified name and type.

Syntax

public EdmSingleton(string name, string type)

Parameters

NameTypeDescription
namestringThe name of the singleton.
typestringThe entity type of the singleton.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when name or type is null or whitespace.

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

Annotations

Gets or sets the annotations for this singleton.

Syntax

public System.Collections.Generic.Dictionary<string, object> Annotations { get; set; }

Property Value

Type: System.Collections.Generic.Dictionary<string, object> A dictionary of annotations that provide additional metadata about the singleton.

Remarks

Annotations can be used to specify additional behaviors, constraints, or metadata that are not captured by the standard OData model elements.

HasNavigationPropertyBindings

Gets a value indicating whether this singleton has any navigation property bindings.

Syntax

public bool HasNavigationPropertyBindings { get; }

Property Value

Type: bool true if the singleton has navigation property bindings; otherwise, false.

Name

Gets or sets the name of the singleton.

Syntax

public required string Name { get; set; }

Property Value

Type: string The name used to address this singleton in OData URLs.

Remarks

The singleton name appears in the URL path when accessing the individual entity. Gets or sets the navigation property bindings for this singleton.

Syntax

public System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmNavigationPropertyBinding> NavigationPropertyBindings { get; set; }

Property Value

Type: System.Collections.Generic.List<Microsoft.OData.Mcp.Core.Models.EdmNavigationPropertyBinding> A collection of navigation property bindings that establish relationships with other entity sets or singletons.

Remarks

Navigation property bindings specify which entity set or singleton should be used when following a navigation property from this singleton. They establish the connections between related resources in the model.

Type

Gets or sets the entity type of the singleton.

Syntax

public required string Type { get; set; }

Property Value

Type: string The fully qualified name of the entity type for this singleton.

Remarks

The singleton instance must be of this entity type or one of its derived types. This determines the structure and properties available for the singleton.

TypeName

Gets the short name of the entity type (without namespace).

Syntax

public string TypeName { get; }

Property Value

Type: string The entity type name without the namespace prefix.

TypeNamespace

Gets the namespace of the entity type.

Syntax

public string TypeNamespace { get; }

Property Value

Type: string The namespace portion of the entity type, or an empty string if no namespace.

Methods

AddAnnotation

Adds an annotation to this singleton.

Syntax

public void AddAnnotation(string term, object value)

Parameters

NameTypeDescription
termstringThe annotation term.
valueobjectThe annotation value.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when term is null or whitespace.

AddNavigationPropertyBinding

Adds a navigation property binding to this singleton.

Syntax

public void AddNavigationPropertyBinding(string navigationPropertyPath, string target)

Parameters

NameTypeDescription
navigationPropertyPathstringThe path of the navigation property.
targetstringThe target entity set or singleton name.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when navigationPropertyPath or target is null or whitespace.

Equals Override

Determines whether the specified object is equal to the current singleton.

Syntax

public override bool Equals(object obj)

Parameters

NameTypeDescription
objobject?The object to compare with the current singleton.

Returns

Type: bool true if the specified object is equal to the current singleton; otherwise, false.

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetAnnotation

Gets an annotation value by term.

Syntax

public T GetAnnotation<T>(string term)

Parameters

NameTypeDescription
termstringThe annotation term.

Returns

Type: T? The annotation value, or the default value of T if not found.

Type Parameters

  • T - The type of the annotation value.

GetHashCode Override

Returns a hash code for the current singleton.

Syntax

public override int GetHashCode()

Returns

Type: int A hash code for the current singleton.

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetNavigationPropertyBinding

Gets a navigation property binding by navigation property path.

Syntax

public Microsoft.OData.Mcp.Core.Models.EdmNavigationPropertyBinding GetNavigationPropertyBinding(string navigationPropertyPath)

Parameters

NameTypeDescription
navigationPropertyPathstringThe path of the navigation property.

Returns

Type: Microsoft.OData.Mcp.Core.Models.EdmNavigationPropertyBinding? The navigation property binding with the specified path, or null if not found.

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

RemoveNavigationPropertyBinding

Removes a navigation property binding from this singleton.

Syntax

public bool RemoveNavigationPropertyBinding(string navigationPropertyPath)

Parameters

NameTypeDescription
navigationPropertyPathstringThe path of the navigation property to remove.

Returns

Type: bool true if the binding was removed; otherwise, false.

ToString Override

Returns a string representation of the singleton.

Syntax

public override string ToString()

Returns

Type: string A string containing the singleton name and type.

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?