Pregunta

We have problem with loading all very big Int64 values from server to client. I think problem is for all numbers larger then 25776087313154050. We using No DB approach of Breeze and makes all metadata manually. Here is metadata:

store.addEntityType({
    shortName: "AdditionalInfoType",
    namespace: "Services",
    autoGeneratedKeyType: breeze.AutoGeneratedKeyType.Identity,
    dataProperties: {
        id: {dataType: breeze.DataType.Int64, isNullable: false, isPartOfKey: true },
        name: { dataType: breeze.DataType.String, isNullable: true },
        dataType: { dataType: breeze.DataType.String, isNullable: false, defaultValue: 'Unknown' }
    },
    navigationProperties: {
        enumItems: {
            entityTypeName: "AdditionalInfoEnumValue", isScalar: false, associationName: "AdditionalInfoEnumValue_AdditionalInfoType"
        }
    }
});

Here is what Fiddler showing from server (data is correct here):

[{"$id":"1","$type":"Services.AdditionalInfoType, Services",
"Name":"Shoe Size","DataType":"Numeric","EnumItems":null,"Id":25776087313154051},
{"$id":"2","$type":"Services.AdditionalInfoType, Services",
"Name":"Floating Holiday","DataType":"Date","EnumItems":null,"Id":25776087313154050}]

Breeze query is pretty simple:

entityQuery.from('AdditionalInfoTypes')
            .toType(entityNames.additionalInfoType)
            .using(employeeManager)

And here what we have in client (unfortunately I can not post images here):

entity[0].id == 25776087313154052
entity[1].id == 25776087313154050

So, Id for second entity correctly loads and have value: 25776087313154050 for both client and server. But for 25776087313154051 server value on client its 25776087313154052.
I did some experiments and found that problem reproducable for all numbers > 25776087313154050 (for both Key part and not). Every time breeze loader increase number by 1.

Any ideas where me wrong or how to solve it?

¿Fue útil?

Solución

That's not a problem related to breeze. The library will simple try to assign the primitive types directly to the properties of the entity. It's apparently an issue with the JavaScript. I think you're reaching the maximum value of the Number type.

Simple try to assign the 25776087313154051 to a property and you will get the value 25776087313154052.

I'm not sure but it seems to be a strange issue with how JavaScript deals with large numbers. May be you can get more info in reading the spec. http://ecma262-5.com/ELS5_HTML.htm#Section_8.5.

What you might try to do to avoid the problem is to change the type of the id property to string.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top