OrientDB-NET.binary
OrientDB-NET.binary copied to clipboard
Cannot properly backtick property name with SetField
To use a space, a dash, a question mark or even "batch" in a property name, it needs to be backticked. This works great with myDB.Create.Property, but SetField keeps the backticks and create new properties with backticks in the name.
So while
myDB.Create.Property("`myProperty`", Type.Bool).Class(myClass).Run();
will create a class myClass
with a property named myProperty
, using after that
aVertex.SetField("`myProperty`", aValue);
will add a property
`myProperty`
and give it a value of aValue and the property myProperty
will stay empty.
To help out with this issue, I'm using the ODocument
object and found it working through that object. Hopefully, this is similar to your use case. But I found that even though you have to provide the backticks when creating class property names, when you set a field value that references the generated property name you no longer have to provide the backticks.
Example
// get our connection
ODatabase myDB = new ODatabase(ConnectionOptions)
// adding the new property to our class
myDB.Create.Property("`myProperty`", Type.Bool).Class(myClass).Run();
// you can simply set the property onto your vertex object without the backticks
aVertex.SetField("myProperty", aValue);