I have tried :
private static PropertyInfo<byte[]> lastmodifProperty = RegisterProperty<byte[]>(c => c.lastmodif);
public byte[] lastmodif
{
get { return GetProperty(lastmodifProperty); }
set { SetProperty(lastmodifProperty, value); }
}
and in Fetch method:
LoadProperty(lastmodifProperty, dr.GetBytes("lastmodif", 0, lastmodif, 0, 8));
This causes the following error on execution:
{"Invalid cast from 'System.Int64' to 'System.Byte[]'."} System.InvalidCastException
If I declare the TimeStamp property Int64, I get the opposite error.
I can do this:
private byte[] _lastmodif = new byte { 0, 0, 0, 0, 0, 0, 0, 0 };
public byte[] Lastmodif
{
get { return _lastmodif; }
}
And this
dr.GetBytes("lastmodif", 0, _lastmodif, 0, 8);
But then the _lastmodif never makes it back to the DB in the Save operation because it is not serialized, I suppose - and hence nothing gets updated.
Would appreciate a hint or two.
Jav
Okay. I can't say that this is the best or the only way to do it, but this will work: (dr is the SafeDataReader)
byte[] _lastmodif = new byte { 0, 0, 0, 0, 0, 0, 0, 0 };
dr.GetBytes("lastmodif", 0, _lastmodif, 0, 8);
LoadProperty(lastmodifProperty, _lastmodif);
Jav
FYI, you can declare byte = new byte; may make it easier than keep count of the number of 0's
I have found it easier to initialize the byte array by setting the default value when registering the property.
private static PropertyInfo<byte[]> TimeStampProperty = RegisterProperty<byte[]>(c => c.TimeStamp, "TimeStamp", new byte);
public byte[] TimeStamp
{
get { return GetProperty(TimeStampProperty); }
private set { SetProperty(TimeStampProperty, value); }
}
Thank you xAvailx and Russ for your suggestions.
Jav
Copyright (c) Marimer LLC