I’ve got a field which its type is byte[]. This field will hold my entity’s RecordVersion property (timestamp in the database). How do I keep this field so that when I save my entity it is available?
I’ve tried two different things and haven’t succeeded so far: This renders ‘System.Byte[]’:
<%= Html.Hidden('RecordVersion', Model.RecordVersion.ToString()) %>
This throws a ModelStateError where the type couldn’t be converted:
ViewData['RecordVersion'] = entity.RecordVersion
Apparently the default MVC’s mechanism that does the bind/unbind doesn’t like much byte[] fields …..
You need to make a modelbinder and register it.
This article shows how to use a timestamp from a linq database in a hidden field much like what you are doing.
In global.asax to register it.
That LinqBinaryModelBinder is in the futures assembly. If you want to user byte[] you’ll have to write one yourself.