Naming a grain
When we create an object of a class using a new operator, what we get is the reference to the memory location. The variable identity is the name we define. If we create another object of the same class, we will get a reference to some other memory space.
As we learned before, grains represent some real-world entities. They exist virtually always. So, grains must have an identity to activate or interact with them. This is fundamentally the primary key of the grain. The scope of the key is the grain type. In the example that we saw in the previous section, Distel.Agra
is the primary key of the hotel grain that we created. It represents the hotel with the name Distel.Agra
. The scope of this identity is limited to hotel grains.
In Orleans, we have three main types of primary keys:
- Integer
- GUID
- String
In addition to these, there are compound keys:
- Integer + string
- GUID + string
The grain key is determined by the interface...