Non-string ID column not fully supported
Quickstart states that
The only assumption is that you'll provide an "Id" property which is a string (though it doesn't have to be a string).
Unfortunately, there is not yet full support for IDs of other types. I tried adding support to Nevermore by changing string casts and parameters to object, but ran into problems with method overload resolution, so I'm not certain if that's the right way.
Problem 1
.Load methods only accept string. Therefore, to load entities of other types, one needs to work around by using .Query
Problem 2
Insert fails because Id column is cast to string.
https://github.com/OctopusDeploy/Nevermore/blob/master/source/Nevermore/Util/DataModificationQueryBuilder.cs#L246
Workaround: use a property handler for ID column that casts to string on Read
public class ReportStateCorrelationIdPropertyHandler : IPropertyHandler
{
public object Read(object target)
{
return ((ReportState)target).CorrelationId.ToString();
}
public void Write(object target, object value)
{
var state = (ReportState)target;
Guid guid = default;
if (value != null)
{
if (value.GetType() == typeof(Guid))
guid = (Guid)value;
else if (value.GetType() == typeof(string))
guid = Guid.Parse((string)value);
}
state.CorrelationId = guid;
}
}
Would be great if Nevermore could handle it. I can submit WIP PR if you want, and you can point me into right direction.
Use case is using Nevermore as MassTransit Saga repository, which uses GUIDs as correlation id.