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
{{ message }}
This repository was archived by the owner on Apr 11, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 11, 2023. It is now read-only.
I'm looking into replacing breeze with jaydata on my project, but i'm struggling with enumerations. I'm using the latest updates from nuget together with oData v4.0. I've generated my context with JaySvcUtil.exe without errors. Is the use of enumerations even possible? Can I define the type myself?
Exception: Unable to resolve type:Erp.Entity.Common.State
Did you take a look at what the responses from your server look like?
I have a Web Api OData v4 service, and enums are returned just like strings.
So a response would look like:
{ 'Name': "my name', 'State': 'Changed' }
If that is the case, for now, just change the type of State in your JayData definition to Edm.String, and then recreate the enum on the javascript side with strings like this:
var state = { Normal: "Normal", Changed: "Changed", Night: "Night" }
Depending on what kind of IDE you are using, you might even get around with just using plain strings, as I think recreating the enum only has advantages if your IDE has some kind of autocomplete for Javascript.
Yes, I did.
Yes, response looked for enum exactly as you say.
But, what about filtering over 'State' property? In case when we difine enum property as string then it should be escaped by ' symbol; and the simplest filter
.filter(function (it) { return it.State== this.state; }, { state: /**???**/'Changed'/**???**/ }) // may be wrong usage, but Edm model, defined by hand, suspect string usage.
Then we got
State eq 'Changed'
, while for enum we have to got (suppose enum name is 'StateEnum', and namespace is 'EnumNamespace'):
State eq EnumNamespace.StateEnum'Changed'
In case of enum isn't used as a collection of flags.
the query would be created as expected (thanks to valueOf method).
BUT, how to register converter to get enum instance during deserialization collection in 'json' is parsed, I don't know. In this case for each entity instance would be called constructor EnumType without parameters. I't is important for me to get to know how to transform string to Enum, could you help me?
Ah, damn, I never used a filter on an enum, so I didn't knew my way of just using it as a string isn't working when filtering. Sorry, I don't have a solution for that right now. :(
Malyngo,
It seems to me too that there is none simple solution for full enum support.
But, are you going in the nearest future start to support enum type?
Activity
Oleg-Tamarintsev commentedon Jun 22, 2015
Are you going to support enumerated types in oData v4.0? I have faced the same problem using jayData v1.4.0 alfa.
Malyngo commentedon Jun 22, 2015
Did you take a look at what the responses from your server look like?
I have a Web Api OData v4 service, and enums are returned just like strings.
So a response would look like:
{ 'Name': "my name', 'State': 'Changed' }
If that is the case, for now, just change the type of State in your JayData definition to Edm.String, and then recreate the enum on the javascript side with strings like this:
var state = { Normal: "Normal", Changed: "Changed", Night: "Night" }
Depending on what kind of IDE you are using, you might even get around with just using plain strings, as I think recreating the enum only has advantages if your IDE has some kind of autocomplete for Javascript.
Oleg-Tamarintsev commentedon Jun 22, 2015
Yes, I did.
Yes, response looked for enum exactly as you say.
But, what about filtering over 'State' property? In case when we difine enum property as string then it should be escaped by ' symbol; and the simplest filter
Then we got
, while for enum we have to got (suppose enum name is 'StateEnum', and namespace is 'EnumNamespace'):
In case of enum isn't used as a collection of flags.
Oleg-Tamarintsev commentedon Jun 22, 2015
I tried to define enum by hand using followning code:
my enum was:
The simplest definition for enum (may be wrong) would be:
In this case:
the query would be created as expected (thanks to valueOf method).
BUT, how to register converter to get enum instance during deserialization collection in 'json' is parsed, I don't know. In this case for each entity instance would be called constructor EnumType without parameters. I't is important for me to get to know how to transform string to Enum, could you help me?
Malyngo commentedon Jun 22, 2015
Ah, damn, I never used a filter on an enum, so I didn't knew my way of just using it as a string isn't working when filtering. Sorry, I don't have a solution for that right now. :(
Oleg-Tamarintsev commentedon Jun 23, 2015
Malyngo,
It seems to me too that there is none simple solution for full enum support.
But, are you going in the nearest future start to support enum type?
Malyngo commentedon Jun 24, 2015
I am myself also just a user of Jaydata, and wanted to help the creator of the issue with this.
Sorry if I have caused some confusion here.
DoubleExposure commentedon Jun 24, 2015
They do not support oData4 just Odata2 which is why I could not use it.
This is primarily based on their dependency on DATA.JS
http://datajs.codeplex.com/.
On Wed, Jun 24, 2015 at 5:05 AM, Rainer Ziller notifications@github.com
wrote:
DoubleExposure commentedon Jun 24, 2015
Ok, I just saw this. So now they do support 4. I wish they had this when I
was trying to use it.
http://jaydata.org/blog/release-notes
On Wed, Jun 24, 2015 at 7:57 AM, Southpoint southpointtech@gmail.com
wrote:
philcarbone commentedon Jul 6, 2017
+1 Need Flags to work (e.g. https://stackoverflow.com/questions/8447/what-does-the-flags-enum-attribute-mean-in-c).
We are getting an error that a string can't be converted to the Enum type (because it is multiple Enum Flags together).
We are using OData v4.
Added New Issue specifically for this: #293