Note that there are some explanatory texts on larger screens.

plurals
  1. POusing breeze.DataType.parseDateFromServer at the breeze-object define
    primarykey
    data
    text
    <p>I work in durandal project and using breeze. I retrive with the server (c#) object from sql into c# class, and it enter to a breeze-object which look exactly like the c# class. when I define in the breeze object property with data-type "date-time", it doesn't convert the date-time of c# to date-time of breeze correctly. I checked and finded the problem: when it arrives to this point, it doesn't work well:</p> <pre class="lang-js prettyprint-override"><code>function __isDate(o) { return __classof(o) === "date" &amp;&amp; !isNaN(o.getTime()); } </code></pre> <p>in the watching-window I see that: __classof(o)=> returns "string"!!!</p> <p>so I looked in your site and see that there is option to use breeze.DataType.parseDateFromServer. but I dont want to use it in the javascript- logic, becouse after it enter the c# object into the breeze object, and doesn't convert it correctly, I lost the original date, and now this option can't help me. so I want to use this option into the breeze-object.</p> <p>here is my code:</p> <pre class="lang-js prettyprint-override"><code>addEmployeePersonalDetailsType(store); function addEmployeePersonalDetailsType(store) { store.addEntityType({ shortName: "EmployeePersonalDetailsDTO", namespace: "eHarmonyServer.Entities", isComplexType: true, dataProperties: { BirthDay: { dataType: DataType.DateTime, isPartOfKey: false , validators: [Validator.date()] }, EmmigrationDate: { dataType: DataType.DateTime, isPartOfKey: false }, JobCode: { dataType: DataType.Int32, isPartOfKey: false }, ChildCount: { dataType: DataType.Int32, isPartOfKey: false, isNullable: false }, str_JobCode: { dataType: DataType.String, isPartOfKey: false }, str_MaritalStatus: { dataType: DataType.String, isPartOfKey: false }, validators: [Validator.double()] }, }); store.registerEntityTypeCtor("EmployeePersonalDetailsDTO", null, null); } </code></pre> <p>I want to write:</p> <pre class="lang-js prettyprint-override"><code> EmmigrationDate: { dataType: DataType.parseDateFromServer, isPartOfKey: false }, </code></pre> <p>but parseDateFromServer is function and it needs to acceps one parameter called "source". what should I send to it? or- do you have another way to solve this problem? thank you very match.</p> <p>sample of class in file model.js:</p> <pre class="lang-js prettyprint-override"><code> addEmployeeMainDataType(store); function addEmployeeMainDataType(store) { store.addEntityType({ shortName: "EmployeeMainDTO", namespace: "eHarmonyServer.Entities", isComplexType: true, dataProperties: { FirstName: { dataType: DataType.String, isNullable: true, isPartOfKey: false, validators: [Validator.required()] }, NickName: { dataType: DataType.String, isNullable: true, isPartOfKey: false }, LastName: { dataType: DataType.String, isNullable: true, isPartOfKey: false, validators: [Validator.required()] }, PassportNo: { dataType: DataType.String, isNullable: true, isPartOfKey: false }, Date_start: { dataType: DataType.DateTime, isNullable: true, isPartOfKey: false, validators: [Validator.required()] }, Date_end: { dataType: DataType.DateTime, isNullable: true, isPartOfKey: false, validators: [Validator.date() , validationHelper.complexTypeEndDateGreaterThanStartDateValidator({ startDateFieldName: "Date_start", resourceId: "1732", entityName: 'employeeTblData', entityNameSub: 'employeeMainData' })] }, HourPrice: { dataType: DataType.Double, isNullable: true, isPartOfKey: false }, xActive: { dataType: DataType.Boolean, isNullable: false, isPartOfKey: false }, BalanceCalc: { dataType: DataType.Boolean, isNullable: false, isPartOfKey: false } } }); store.registerEntityTypeCtor("EmployeeMainDTO", null, employeeMainDataInit); } </code></pre> <p>as you can see, I have more than one property from type "dateTime": Date_start, Date_end. and I have a few classes else, which have properties of dateTime type, too. so, the solution that suggest me to write initializer function for each field which is type date- is not good for me. I want that instead of write :</p> <pre class="lang-js prettyprint-override"><code> Date_start: { dataType: DataType.DateTime, isNullable: true, Date_end: { dataType: DataType.DateTime, isNullable: true, </code></pre> <p>you will give me another type to write, that I will need to add only one converter function to code, and it will be generic function, not relative to specific field-name, such "birthday", "Data_end", etc.</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.
    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