Note that there are some explanatory texts on larger screens.

plurals
  1. PObreezejs addEntityType issue
    primarykey
    data
    text
    <p>I'm new to breezejs. I am trying to define my entity type in the client without getting metadata from the server. I have a property called ID in the server entity.</p> <p>I've defaulted the naming convention in the client side to camel case using the following code.</p> <pre><code>breeze.NamingConvention.camelCase.setAsDefault(); </code></pre> <p>so, I started to map the entity as follows</p> <pre><code>store.addEntityType({ shortName: "Photo", namespace: "MyProj.Models", dataProperties: { id: { dataType: DataType.Guid, isNullable: false, isPartOfKey: true }, title: { dataType: DataType.String }, description: { dataType: DataType.String }, createdDate: { dataType: DataType.DateTime }, } }); </code></pre> <p>This worked all fine, except the id field is not getting the proper value. instead, it has the default value set by the breeze datatype ctor which is equals to <code>Guid.Empty</code>.</p> <p>by stepping through breezejs debug script, I found out that it looks for a property name called <code>Id</code> in the data that comes from the ajax request. But it can't find it as the property is <code>ID</code> so it initialize it to <code>empty guid</code> string. I assumed that by setting <code>nameOnServer</code> property of the <code>dataProperty</code> <code>id</code>, I will be able to fix it.</p> <pre><code>store.addEntityType({ shortName: "Photo", namespace: "MyProj.Models", dataProperties: { id: { dataType: DataType.Guid, isNullable: false, nameOnServer: 'ID', isPartOfKey: true }, title: { dataType: DataType.String }, description: { dataType: DataType.String }, createdDate: { dataType: DataType.DateTime }, } }); </code></pre> <p>But it didn't work.</p> <p>Further digging through the breez.debug.js code, in the method <code>updateClientServerNames</code> on line 7154, it seems it ignores the <code>nameOnServer</code> that I have defined.</p> <p>Am I missing something here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload