I'm engaged in a minor skirmish with Dynamic Data. I've got a custom database image field template to allow users to upload and edit images where inserting works but updating does not. I can make update work by removing the if insert mode around where the uri
is set in the following code (in DBImage_Edit.ascx.cs):
protected override void ExtractValues(IOrderedDictionary dictionary)
{
...
dictionary["contenttype"] = "image/" + imgext;
dictionary["filecontents"] = new System.Data.Linq.Binary(FileUploadEdit.FileBytes);
if (Mode == DataBoundControlMode.Insert)
{
dictionary["uri"] = imgname + "_" + DateTimeOffset.Now.Ticks.ToString() + "." + imgext;
}
...
}
To recap, if the uri is set to something different than the previous value in the DB when editing, the new image is uploaded successfully. If the uri is the same as the previous value in the DB, even though the filecontents and contenttype are changed, SQL Server never gets the news.
The metadata:
...
[DisplayName("Uri")]
[ScaffoldColumn(true)]
[Required]
public object uri { get; set; }
[DisplayName("Graphic")]
[ScaffoldColumn(true)]
[UIHint("DBImage")]
public object filecontents { get; set; }
...
I've also removed the UpdateCheck but that did not seem to change the behavior:
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_filecontents", DbType="VarBinary(MAX)")] //, UpdateCheck=UpdateCheck.Never
public System.Data.Linq.Binary filecontents
{
get
{
...
(See commented out UpdateCheck=UpdateCheck.Never above)
Kind regards,
Jordan