Is it possible to work with immutable types? #529
-
As we discussed earlier #72 if I use F# types like records and discriminated unions I cannot inherit any base class. And the only way to construct the class is via an exhaustive default constructor that sets all the fields. Is it correct that now I can create my vertexes without inheriting the base class? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This might work for Id and Label, since these values are on the top-level of a GraphSON vertex, but for everything that's below the "properties" property of a GraphSON vertex, the POCO will already be created and just need to be populated, so there must be setters for these. After all, these are just POCOs. I like immutability as well (everything in Gremlinq is immutable), but when it comes to entities, it's just data, and hopefully no one ever does any threading-sensitive operations on these. I know this doesn't go too well with records (C# nor F#), but this is the current state of things. Yes you don't need to inherit the base class that comes with ExRam.Gremlinq, but for model creation, there should be some base classes for edges and vertices, otherwise all the nice inheritance features won't work properly. |
Beta Was this translation helpful? Give feedback.
This might work for Id and Label, since these values are on the top-level of a GraphSON vertex, but for everything that's below the "properties" property of a GraphSON vertex, the POCO will already be created and just need to be populated, so there must be setters for these. After all, these are just POCOs. I like immutability as well (everything in Gremlinq is immutable), but when it comes to entities, it's just data, and hopefully no one ever does any threading-sensitive operations on these. I know this doesn't go too well with records (C# nor F#), but this is the current state of things.
Yes you don't need to inherit the base class that comes with ExRam.Gremlinq, but for model creation…