Type facets
Applies To: # OData core lib v7 supported OData Core Lib V7
Users can specify various type facets for references to type definitions. The only constraint is that the type facets specified should be applicable to the underlying type definition.
If you want to specify type facets, you need to call this constructor:
public EdmTypeDefinitionReference(
IEdmTypeDefinition typeDefinition,
bool isNullable,
bool isUnbounded,
int? maxLength,
bool? isUnicode,
int? precision,
int? scale,
int? spatialReferenceIdentifier);
Here is sample code to create an EDM type definition reference with type facets
IEdmTypeDefinition typeDefinition = new EdmTypeDefinition("MyNS", "Title", EdmPrimitiveTypeKind.String);
IEdmTypeDefinitionReference reference = new EdmTypeDefinitionReference(
typeDefinition,
isNullable: true,
isUnbounded: false,
maxLength: 10,
isUnicode: true,
precision: null,
scale: null,
spatialReferenceIdentifier: null);
isNullable
:true
to allownull
values;false
otherwise.isUnbounded
:true
to indicateMaxLength="max"
;false
to indicate that theMaxLength
is a bounded value.maxLength
:null
for unspecified; other values for specified lengths. Invalid ifisUnbounded
istrue
.isUnicode
:true
if the encoding is Unicode;false
for non-Unicode encoding;null
for unspecified.precision
:null
for unspecified; other values for specified precisions; MUST be non-negative.scale
:null
to indicateScale="variable"
; other values for specified scales; MUST be non-negative.spatialReferenceIdentifier
:null
to indicateSRID="variable"
; other values for specified SRIDs; MUST be non-negative.
It's worth mentioning that if you call the overloaded constructor taking two parameters, all the type facets will be auto-computed according to the OData protocol. For example, the default value of SRID
is 0
for geometry types and 4326
for geography types.
public EdmTypeDefinitionReference(
IEdmTypeDefinition typeDefinition,
bool isNullable);