Show:

NamingConvention Class

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.

Methods

<ctor> NamingConvention

(
  • config
)

NamingConvention constructor

Parameters:

  • config Object
    • serverPropertyNameToClient Function

      Function that takes a server property name add converts it into a client side property name.

    • clientPropertyNameToServer Function

      Function that takes a client property name add converts it into a server side property name.

Example:

// 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 });

clientPropertyNameToServer

(
  • clientPropertyName
  • [property]
)
String

The function used to convert client side property names to server side property names.

Parameters:

  • clientPropertyName String
  • [property] DataProperty | NavigationProperty optional

    The actual DataProperty or NavigationProperty corresponding to the property name.

Returns:

String:

The server side property name.

serverPropertyNameToClient

(
  • serverPropertyName
  • [property]
)
String

The function used to convert server side property names to client side property names.

Parameters:

  • serverPropertyName String
  • [property] DataProperty | NavigationProperty optional

    The actual DataProperty or NavigationProperty corresponding to the property name.

Returns:

String:

The client side property name.

setAsDefault

() chainable

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.

Example:

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();

Properties

camelCase

NamingConvention static

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

NamingConvention static

The default value whenever NamingConventions are not specified.

none

NamingConvention static

A noop naming convention - This is the default unless another is specified.