breeze-client / NamingConvention
Class: NamingConvention
Defined in: src/metadata/naming-convention.ts:23
A NamingConvention instance is used to specify the naming conventions under which a MetadataStore will translate property names between the server and the javascript client.
The default NamingConvention does not perform any translation, it simply passes property names thru unchanged.
Constructors
Constructor
new NamingConvention(
ncConfig):NamingConvention
Defined in: src/metadata/naming-convention.ts:50
NamingConvention constructor
// A naming convention that converts the first character of every property name to uppercase on the server
// and lowercase on the client.
var namingConv = new NamingConvention({
serverPropertyNameToClient: function(serverPropertyName) {
return serverPropertyName.substr(0, 1).toLowerCase() + serverPropertyName.substr(1);
},
clientPropertyNameToServer: function(clientPropertyName) {
return clientPropertyName.substr(0, 1).toUpperCase() + clientPropertyName.substr(1);
}
});
var ms = new MetadataStore({ namingConvention: namingConv });
var em = new EntityManager( { metadataStore: ms });Parameters
ncConfig
Returns
NamingConvention
Properties
clientPropertyNameToServer
clientPropertyNameToServer: (
nm,context?) =>string
Defined in: src/metadata/naming-convention.ts:31
Function that takes a client property name add converts it into a server side property name. Read Only
Parameters
nm
string
context?
any
Returns
string
name
name:
string
Defined in: src/metadata/naming-convention.ts:27
The name of this NamingConvention. Read Only
serverPropertyNameToClient
serverPropertyNameToClient: (
nm,context?) =>string
Defined in: src/metadata/naming-convention.ts:29
Function that takes a server property name add converts it into a client side property name. Read Only
Parameters
nm
string
context?
any
Returns
string
camelCase
staticcamelCase:NamingConvention
Defined in: src/metadata/naming-convention.ts:83
The "camelCase" naming convention - This implementation only lowercases the first character of the server property name but leaves the rest of the property name intact. If a more complicated version is needed then one should be created via the ctor.
defaultInstance
staticdefaultInstance:NamingConvention
Defined in: src/metadata/naming-convention.ts:97
The default value whenever NamingConventions are not specified: camelCase, which suits a .NET server. (2.x defaulted to none.)
none
staticnone:NamingConvention
Defined in: src/metadata/naming-convention.ts:69
/** A no-op naming convention: client property names are the server property names. Set it with NamingConvention.none.setAsDefault() for a server that already sends the names the client should use.
Methods
setAsDefault()
setAsDefault():
any
Defined in: src/metadata/naming-convention.ts:114
Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance. The current instance is returned unchanged.
var namingConv = new NamingConvention({
serverPropertyNameToClient: function(serverPropertyName) {
return serverPropertyName.substr(0, 1).toLowerCase() + serverPropertyName.substr(1);
},
clientPropertyNameToServer: function(clientPropertyName) {
return clientPropertyName.substr(0, 1).toUpperCase() + clientPropertyName.substr(1);
}
});
namingConv.setAsDefault();Returns
any