I have a 'save' function on my webform that will update an entity which has a byte array property for blob objects. Everything works fine if I select all entity properties and then saving using this code:
Code:
Certification c = new Certification();
c.LoadByPrimaryKey(Convert.ToInt32(ViewState["cId"]));
//fill other properties here
byte[] bytes = new byte[RadUpload1.UploadedFiles[0].InputStream.Length];
RadUpload1.UploadedFiles[0].InputStream.Read(bytes, 0, Convert.ToInt32(RadUpload1.UploadedFiles[0].InputStream.Length));
c.File = bytes;
c.Save();
There is no reason to load the blob from the database if it isn't going to change or if I'm just going to overwrite that property and send the bytes back to the database. What I'd like to be able to do is this:
Code:
Certification c = new Certification();
//load all properties except the blob
esQueryItem qi = new esQueryItem(c.Query, CertificationMetadata.ColumnNames.File, esSystemType.ByteArray);
c.Query.SelectAllExcept(qi).Where(c.Query.Id == Convert.ToInt32(ViewState["cId"]));
c.Query.Load();
//fill other properties here
byte[] bytes = new byte[RadUpload1.UploadedFiles[0].InputStream.Length];
RadUpload1.UploadedFiles[0].InputStream.Read(bytes, 0, Convert.ToInt32(RadUpload1.UploadedFiles[0].InputStream.Length));
c.File = bytes;
c.Save();
Unfortunately, when I try to assign 'bytes' to 'c.File' using my preferred method of using the 'SelectAllExcept' method, the property remains null and does not save.
Am I doing something wrong or is this just not possible for some reason.
Thanks is advance,
Paul