You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been looking at using NodaTime on my entities and am unable to get BreezeJS to treat NodaTime values as a JS Date. In the metadata the property's datatypes are the NodaTime type (e.g. NodaTime.LocalDate) which doesn't map to the BreezeJS DataType.DateTime. Side note, is this going to be an issue for the new .NET 6 DateOnly and TimeOnly data types?
Ideally, there would be some way to be able to transparently map these types to a JS Date, but there doesn't seem to be a way to do this unless I'm missing something.
I explored a few different ideas and there are a few ways I think this could be achieved, in descending order of what I think would be most preferable:
Some way to register a custom DataType which has custom (de)serialisation logic (e.g. from NodaTime.LocalDate to JS Date), however currently in BreezeJS DataType is an Enum which precludes any registration of custom types.
Be able to alias a given DataType from metadata to an already implemented DataType in JS. This might work for deserialisation, but is likely to have issues when serialising for the server to handle (e.g. server is expecting a LocalDate and recieves an full timestamp)
Hacking the metadata to force NodaTime types to be a DateTime. While this possibly might work for my specific use case, I would think a more flexible option is preferable
I managed to create wrapper properties on my JS entities which handle conversion between the raw string property (which BreezeJs falls back to) and a date, but this is repetitive and error prone. Perhaps if there is an automated way I could achieve this with the raw string property being a shadow property that would work but I feel there are better approaches
Create DTO versions of each entity with System.DateTime properties which will be handled by the client correctly. This seems to go against the philosophy of breeze, adding duplication and uneccessary mapping logic between the actual entities and the DTOs.
Any thoughts from someone with more experience with Breeze would be most appreciated.
The text was updated successfully, but these errors were encountered:
I have been looking at using NodaTime on my entities and am unable to get BreezeJS to treat NodaTime values as a JS
Date
. In the metadata the property's datatypes are the NodaTime type (e.g.NodaTime.LocalDate
) which doesn't map to the BreezeJSDataType.DateTime
. Side note, is this going to be an issue for the new .NET 6DateOnly
andTimeOnly
data types?Ideally, there would be some way to be able to transparently map these types to a JS Date, but there doesn't seem to be a way to do this unless I'm missing something.
I explored a few different ideas and there are a few ways I think this could be achieved, in descending order of what I think would be most preferable:
DataType
which has custom (de)serialisation logic (e.g. fromNodaTime.LocalDate
to JS Date), however currently in BreezeJSDataType
is an Enum which precludes any registration of custom types.System.DateTime
properties which will be handled by the client correctly. This seems to go against the philosophy of breeze, adding duplication and uneccessary mapping logic between the actual entities and the DTOs.Any thoughts from someone with more experience with Breeze would be most appreciated.
The text was updated successfully, but these errors were encountered: