We are storing a simple textstring property with the following format: ##-### or 12-377. We'll say this property has an alias of prop.
We then load the node as follows:
dynamic node= new DynamicNode(nodeId)
and try and retrieve the data as follows:
string propValue = node.prop;
An exception is thrown because somehow the value is being interpreted as a date. When clearly it is not. I created a test and I know that dynamic alone will not auto convert a string with this format to a date so it has to be something wrong with dynamic node. Can we confirm that this is a bug? Is there another solution where we can store a 'string' and not have it's value automatically converted?
I'm having to use getproperty as a workaround, but I don't like workarounds, especially not in this case. This is clearly an issue that could very easily bite us again. I don't want to be afraid that just because of how something is stored that it could potentially break. It's a textstring, there is no reason for dynamicnode to be looking into it's contents to figure out what it is and change it's type.
These are not really workarounds, but intended behaviour. Part of doing ducktyping / dynamic typing is that sometimes it'll be wrong. If you need to do your own typing, GetProperty(Value) needs to be used.
Sorry, both are not possible. You CAN, however change your razor scripts and turn everything into GetProperty instead of Model.propName.. That would make 100% sure that this doesn't happen again.
Textstring being returned as a datetime.
We are storing a simple textstring property with the following format: ##-### or 12-377. We'll say this property has an alias of prop.
We then load the node as follows:
dynamic node= new DynamicNode(nodeId)
and try and retrieve the data as follows:
string propValue = node.prop;
An exception is thrown because somehow the value is being interpreted as a date. When clearly it is not. I created a test and I know that dynamic alone will not auto convert a string with this format to a date so it has to be something wrong with dynamic node. Can we confirm that this is a bug? Is there another solution where we can store a 'string' and not have it's value automatically converted?
I'm having to use getproperty as a workaround, but I don't like workarounds, especially not in this case. This is clearly an issue that could very easily bite us again. I don't want to be afraid that just because of how something is stored that it could potentially break. It's a textstring, there is no reason for dynamicnode to be looking into it's contents to figure out what it is and change it's type.
You can get the pure text in 4.7.0 by using:
or in 4.7.1:
These are not really workarounds, but intended behaviour. Part of doing ducktyping / dynamic typing is that sometimes it'll be wrong. If you need to do your own typing, GetProperty(Value) needs to be used.
Damnit I accidentally clicked the solved button. This is in fact not helpful. As I mentioned already this exact 'workaround' above.
However our sites are already coded with a different pattern and at any time they could go up in smoke because dynamic node is broken.
What I was looking for, if I was not explicit enough, is how I can set a datatype to return exactly as a string and not something else entirely.
If its possible, please 'unsolve' this issue.
Sorry, both are not possible. You CAN, however change your razor scripts and turn everything into GetProperty instead of Model.propName.. That would make 100% sure that this doesn't happen again.
is working on a reply...