breeze-client / DataProperty
Class: DataProperty
Defined in: src/metadata/entity-metadata.ts:2293
A DataProperty describes the metadata for a single property of an EntityType that contains simple data.
Instances of the DataProperty class are constructed automatically during Metadata retrieval. However it is also possible to construct them directly via the constructor.
Constructors
Constructor
new DataProperty(
config):DataProperty
Defined in: src/metadata/entity-metadata.ts:2370
DataProperty constructor
const lastNameProp = new DataProperty({
name: "lastName",
dataType: DataType.String,
isNullable: true,
maxLength: 20
});
// assuming personEntityType is a newly constructed EntityType
personEntityType.addProperty(lastNameProp);Parameters
config
DataProperty | DataPropertyConfig
A configuration Object or a DataProperty
Returns
DataProperty
Properties
baseProperty?
optionalbaseProperty?:DataProperty
Defined in: src/metadata/entity-metadata.ts:2355
Property on the base type that this property is inherited from. Will be null if the property is not on the base type. Read Only
complexType?
optionalcomplexType?:ComplexType
Defined in: src/metadata/entity-metadata.ts:2309
The ComplexType associated with this property; may be undefined. Read Only
complexTypeName
complexTypeName:
string
Defined in: src/metadata/entity-metadata.ts:2307
The name of the ComplexType associated with this property; may be null. Read Only
concurrencyMode
concurrencyMode:
string
Defined in: src/metadata/entity-metadata.ts:2328
How this property takes part in optimistic concurrency checking, as the server reported it. Any value other than "None" puts the property into EntityType.concurrencyProperties, whose values Breeze sends with a save so the server can detect that someone else changed the row first. A Breeze .NET server reports "Fixed" for a rowversion or [ConcurrencyCheck] property. Read Only
custom?
optionalcustom?:any
Defined in: src/metadata/entity-metadata.ts:2341
A free form object that can be used to define any custom metadata for this DataProperty. Read Only
dataType
dataType:
ComplexType|DataType
Defined in: src/metadata/entity-metadata.ts:2305
The DataType of this property. Read Only
defaultValue
defaultValue:
any
Defined in: src/metadata/entity-metadata.ts:2317
The default value for this property. Read Only
displayName
displayName:
string
Defined in: src/metadata/entity-metadata.ts:2335
The display name of this property. Read Only
enumType?
optionalenumType?:string
Defined in: src/metadata/entity-metadata.ts:2337
The full name of the enum type
inverseNavigationProperty?
optionalinverseNavigationProperty?:NavigationProperty
Defined in: src/metadata/entity-metadata.ts:2348
For a foreign key in a unidirectional relationship, the navigation property on the other type that points back at this one. It is set only when the type holding the foreign key has no navigation property of its own for it: Territory.regionId has no Territory.region, so its inverseNavigationProperty is Region.territories, and setting the foreign key still maintains that collection. Where both sides do have a navigation property, DataProperty.relatedNavigationProperty is set instead. Read Only
isComplexProperty
isComplexProperty:
boolean
Defined in: src/metadata/entity-metadata.ts:2311
Whether the contents of this property is an instance of a ComplexType. Read Only
isDataProperty
isDataProperty:
boolean=true
Defined in: src/metadata/entity-metadata.ts:2297
Is this a DataProperty? - always true here. Allows polymorphic treatment of DataProperties and NavigationProperties. Read Only
isNavigationProperty
isNavigationProperty:
boolean=false
Defined in: src/metadata/entity-metadata.ts:2299
Is this a NavigationProperty? - always false here. Allows polymorphic treatment of DataProperties and NavigationProperties. Read Only
isNullable
isNullable:
boolean
Defined in: src/metadata/entity-metadata.ts:2313
Whether this property is nullable. Read Only
isPartOfKey
isPartOfKey:
boolean
Defined in: src/metadata/entity-metadata.ts:2319
Whether this property is a 'key' property. Read Only
isScalar
isScalar:
boolean
Defined in: src/metadata/entity-metadata.ts:2315
Whether this property is scalar (i.e., returns a single value as opposed to an array). Read Only
isSettable
isSettable:
boolean
Defined in: src/metadata/entity-metadata.ts:2323
Whether this property is 'settable'. Read Only
isUnmapped
isUnmapped:
boolean
Defined in: src/metadata/entity-metadata.ts:2321
Whether this property is an 'unmapped' property. Read Only
maxLength?
optionalmaxLength?:number
Defined in: src/metadata/entity-metadata.ts:2330
The maximum length for the value of this property. Only meaningful for strings. Read Only
name
name:
string
Defined in: src/metadata/entity-metadata.ts:2301
The name of this property. Read Only
nameOnServer
nameOnServer:
string
Defined in: src/metadata/entity-metadata.ts:2303
The name of this property on the server. Read Only
parentType
parentType:
StructuralType
Defined in: src/metadata/entity-metadata.ts:2353
The parent type that this property belongs to - will be either a EntityType or a ComplexType. Read Only
rawTypeName?
optionalrawTypeName?:string
Defined in: src/metadata/entity-metadata.ts:2339
The raw type name of this property. will only be defined for properties with a DataType of 'Undefined'
relatedNavigationProperty?
optionalrelatedNavigationProperty?:NavigationProperty
Defined in: src/metadata/entity-metadata.ts:2351
The navigation property related to this property. Will only be set if this is a foreign key property. Read Only
validators
validators:
Validator[]
Defined in: src/metadata/entity-metadata.ts:2333
The Validator instances that are associated with this property. Validators can be added and removed from this collection. Read Only
Methods
formatName()
formatName():
string
Defined in: src/metadata/entity-metadata.ts:2487
Returns a name that identifies this property across the store: the qualified name of its parent type and the property name, joined by --. Breeze uses it in error messages and to generate association names; applications do not normally need it.
Returns
string
getAllValidators()
getAllValidators():
Validator[]
Defined in: src/metadata/entity-metadata.ts:2512
Returns the validators that apply to this property: its own DataProperty.validators followed by those of the properties it inherits from on base types. Returns a new array.
Returns
resolveProperty()
resolveProperty(
propName):any
Defined in: src/metadata/entity-metadata.ts:2474
Returns the value of the named field of this property, such as "displayName". If it is null or undefined here, the value is taken from the property this one inherits from on a base type (see DataProperty.baseProperty), and so on up the hierarchy. Validation uses it to find a property's display name.
Parameters
propName
string
Returns
any
setProperties()
setProperties(
config):void
Defined in: src/metadata/entity-metadata.ts:2503
General purpose property set method
// assume myEntityType is an EntityType
const prop = myEntityType.getProperty("myProperty");
prop.setProperties({
custom: { foo: 7, bar: "test" }
});Parameters
config
A configuration object.
custom?
Object
displayName?
string
Returns
void
toJSON()
toJSON():
Object
Defined in: src/metadata/entity-metadata.ts:2525
Returns this property's metadata as a plain object in Breeze's native JSON metadata format, leaving out default values; a complex property is described by its complexTypeName. Used when MetadataStore.exportMetadata serializes the store.
Returns
Object
fromJSON()
staticfromJSON(json):DataProperty
Defined in: src/metadata/entity-metadata.ts:2553
Creates a DataProperty from the JSON form that DataProperty.toJSON produces. Used by MetadataStore.importMetadata. A dataType name the client does not know becomes DataType.Undefined, with the name kept in rawTypeName and a console warning. Modifies the object passed in.
Parameters
json
any
Returns
DataProperty
getRawValueFromClient()
staticgetRawValueFromClient(rawEntity,dp):any
Defined in: src/metadata/entity-metadata.ts:2463
Reads a property's value from a raw entity whose keys are client property names, such as an entity in the output of EntityManager.exportEntities. Returns the property's defaultValue when the raw entity has no value for it. The client-name counterpart of DataProperty.getRawValueFromServer; applications do not normally need it.
Parameters
rawEntity
Object & Record<string, any>
dp
DataProperty
Returns
any
getRawValueFromServer()
staticgetRawValueFromServer(rawEntity,dp):any
Defined in: src/metadata/entity-metadata.ts:2448
Reads a property's value from a raw entity whose keys are server property names, such as a node in query results. Returns the property's defaultValue when the node has no value for it; for an unmapped property it reads nameOnServer, falling back to name, and applies no default. Pass it as the rawValueFn of EntityType.getEntityKeyFromRawEntity when writing an adapter; applications do not normally need it.
Parameters
rawEntity
Object & Record<string, any>
dp
DataProperty
Returns
any