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.EdmProperty

Summary

Represents a property in an OData entity type or complex type.

Remarks

Properties define the structure and data characteristics of entity types and complex types. They specify the name, type, and various constraints of the data elements.

Constructors

.ctor

Initializes a new instance of the EdmProperty class.

Syntax

public EdmProperty()

.ctor

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

Syntax

public EdmProperty(string name, string type)

Parameters

NameTypeDescription
namestringThe name of the property.
typestringThe type of the property.

Exceptions

ExceptionDescription
ArgumentExceptionThrown when name or type is null or whitespace.

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

DefaultValue

Gets or sets the default value of the property.

Syntax

public string DefaultValue { get; set; }

Property Value

Type: string? The default value as a string, or null if not specified.

Remarks

The default value is represented as it appears in the CSDL metadata. Type-specific parsing is required when using this value.

Description

Gets or sets the description of the property.

Syntax

public string Description { get; set; }

Property Value

Type: string? A human-readable description of the property’s purpose.

ElementType

Gets the element type for collection properties.

Syntax

public string ElementType { get; }

Property Value

Type: string The element type of the collection, or the type itself if not a collection.

HasDefaultValue

Gets a value indicating whether the property has a default value.

Syntax

public bool HasDefaultValue { get; }

Property Value

Type: bool true if the property has a default value; otherwise, false.

IsCollection

Gets a value indicating whether this property represents a collection type.

Syntax

public bool IsCollection { get; }

Property Value

Type: bool true if the property type is a collection; otherwise, false.

IsKey

Gets or sets a value indicating whether this property is part of the entity key.

Syntax

public bool IsKey { get; set; }

Property Value

Type: bool true if the property is a key property; otherwise, false.

Remarks

Key properties uniquely identify an entity instance and are typically non-nullable.

IsNullable

Gets a value indicating whether the property is nullable (alias for Nullable property).

Syntax

public bool IsNullable { get; }

Property Value

Type: bool true if the property is nullable; otherwise, false.

IsPrimitive

Gets a value indicating whether this property represents a primitive type.

Syntax

public bool IsPrimitive { get; }

Property Value

Type: bool true if the property type is an EDM primitive type; otherwise, false.

MaxLength

Gets or sets the maximum length of the property value.

Syntax

public System.Nullable<int> MaxLength { get; set; }

Property Value

Type: System.Nullable<int> The maximum length, or null if not specified.

Remarks

This constraint applies primarily to string and binary properties. A value of “Max” in the metadata is represented as null here.

Name

Gets or sets the name of the property.

Syntax

public required string Name { get; set; }

Property Value

Type: string The property name as defined in the CSDL metadata.

Nullable

Gets or sets a value indicating whether the property can contain null values.

Syntax

public bool Nullable { get; set; }

Property Value

Type: bool true if the property is nullable; otherwise, false.

Remarks

When not specified in the metadata, this property defaults to true for most types, except for key properties which are typically non-nullable.

Precision

Gets or sets the precision of the property value.

Syntax

public System.Nullable<int> Precision { get; set; }

Property Value

Type: System.Nullable<int> The precision, or null if not specified.

Remarks

Precision applies to decimal and temporal types, indicating the total number of digits.

Scale

Gets or sets the scale of the property value.

Syntax

public System.Nullable<int> Scale { get; set; }

Property Value

Type: System.Nullable<int> The scale, or null if not specified.

Remarks

Scale applies to decimal types, indicating the number of digits after the decimal point. A value of “Variable” in the metadata is represented as null here.

SRID

Gets or sets the SRID (Spatial Reference System Identifier) for spatial properties.

Syntax

public string SRID { get; set; }

Property Value

Type: string? The SRID value, or null if not applicable or not specified.

Remarks

This property is relevant only for geography and geometry types.

Type

Gets or sets the type of the property.

Syntax

public required string Type { get; set; }

Property Value

Type: string The fully qualified type name (e.g., “Edm.String”, “Namespace.EntityType”).

TypeName

Gets the type name of the property (alias for Type property).

Syntax

public string TypeName { get; }

Property Value

Type: string The fully qualified type name (e.g., “Edm.String”, “Namespace.EntityType”).

Unicode

Gets or sets a value indicating whether the property uses Unicode encoding.

Syntax

public System.Nullable<bool> Unicode { get; set; }

Property Value

Type: System.Nullable<bool> true if Unicode is enabled; false if disabled; null if not specified.

Remarks

This property applies to string properties and affects how the data is stored and transmitted.

Methods

Equals Override

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

Syntax

public override bool Equals(object obj)

Parameters

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

Returns

Type: bool true if the specified object is equal to the current property; 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

GetHashCode Override

Returns a hash code for the current property.

Syntax

public override int GetHashCode()

Returns

Type: int A hash code for the current property.

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

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

ToString Override

Returns a string representation of the property.

Syntax

public override string ToString()

Returns

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

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?