This is a migrated thread and some comments may be shown as answers.

Update byte[] validation error

4 Answers 48 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Petr Šatka
Top achievements
Rank 1
Petr Šatka asked on 30 May 2011, 06:32 PM
Hi Telerik.
I have a problem again. I can not update the image column DATA in my table via the RIA Services. Insert works fine, but update has the validation error "Index was outside the bounds of the array".

In Fidler log, you can see that the error was thrown by Telerik.OpenAccess.Ria.AttachChanges.FindChanges().

Thank you for your help.

Regards.
Peter

Fidler log
@_SubmitChangesResponse__http://tempuri.org/@_SubmitChangesResult  _a_DomainServices       _i)http://www.w3.org/2001/XMLSchema-instance^_ChangeSetEntry^_Entity._type�
b:W_USERDATA       _b@http://schemas.datacontract.org/2004/07/WebTime11.Web.ANeTCommon__DATA�u_SerV3_����\System.DateTime, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e���������~�X̟____IXS_REF�
TEST        __KEY�_DateFrom__OpenAccessGenerated       _c9http://schemas.microsoft.com/2003/10/Serialization/Arrays`_string��<?xml version="1.0" encoding="utf-16"?>
 
<ObjectKey T="WebTime11.Web.ANeTCommon.W_USERDATA" X="AAEAAAD/////AQAAAAAAAAAQAQAAAAQAAAAJAgAAAAkDAAAADQIRAgAAAAIAAAAGBAAAAANLRVkGBQAAAAdJWFNfUkVGEAMAAAACAAAABgYAAAAIRGF0ZUZyb20GBwAAAAxURVNUICAgICAgICAL" />_`_string�_+__^
 
EntityActions._nil�       _b9http://schemas.microsoft.com/2003/10/Serialization/Arrays_^_HasMemberChanges�^_Id�^       Operation�_Update^
StoreEntity._type�
b:W_USERDATA       _b@http://schemas.datacontract.org/2004/07/WebTime11.Web.ANeTCommon__DATA�u_SerV3_����\System.DateTime, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e���������~�X̟____IXS_REF�
TEST        __KEY�_DateFrom__OpenAccessGenerated       _c9http://schemas.microsoft.com/2003/10/Serialization/Arrays`_string��<?xml version="1.0" encoding="utf-16"?>
 
<ObjectKey T="WebTime11.Web.ANeTCommon.W_USERDATA" X="AAEAAAD/////AQAAAAAAAAAQAQAAAAQAAAAJAgAAAAkDAAAADQIRAgAAAAIAAAAGBAAAAANLRVkGBQAAAAdJWFNfUkVGEAMAAAACAAAABgYAAAAIRGF0ZUZyb20GBwAAAAxURVNUICAgICAgICAL" />_`_string�_+__^_ValidationErrors^_ValidationResultInfo^       ErrorCode��_^_Message�*Index was outside the bounds of the array.^_SourceMemberNames       _b9http://schemas.microsoft.com/2003/10/Serialization/Arrays__string�_DATA_^
 
StackTrace�8_   at System.Array.InternalGetReference(Void* elemRef, Int32 rank, Int32* pIndices)
 
   at System.Array.GetValue(Int32 index)
 
   at Telerik.OpenAccess.Ria.AttachChanges.IsDifferent(Object orig, Object client, Type t)
 
   at Telerik.OpenAccess.Ria.AttachChanges.FindChanges(ChangeSetEntry entry, List`1& changes)__^_ValidationResultInfo^ ErrorCode��_^_Message�*Index was outside the bounds of the array.^_SourceMemberNames  _b9http://schemas.microsoft.com/2003/10/Serialization/Arrays__string�_DATA_^
 
StackTrace�8_   at System.Array.InternalGetReference(Void* elemRef, Int32 rank, Int32* pIndices)
 
   at System.Array.GetValue(Int32 index)
 
   at Telerik.OpenAccess.Ria.AttachChanges.IsDifferent(Object orig, Object client, Type t)
 
   at Telerik.OpenAccess.Ria.AttachChanges.FindChanges(ChangeSetEntry entry, List`1& changes)______

Update code example
ANeTCommonDomainContext dc = new ANeTCommonDomainContext();
dc.Load(dc.GetWUSERDATAQuery().Where(userdata => ((userdata.IXS_REF == "TEST") && (userdata.KEY == key))), (o) => {
 
   W_USERDATA userdata = o.Entities.FirstOrDefault();
   if (userdata != null) {
      userdata.DATA = new byte[5] {1,0,0,0,0};
   }
   dc.SubmitChanges((op) => {
      if (op.HasError) op.MarkErrorAsHandled();
   }, null);
}, null);

Table definition
CREATE TABLE [w_userdata] (
    [key] varchar(255) NOT NULL,         -- _KEY
    [ixs_ref] varchar(255) NOT NULL,   -- _IXSREF
    [data] image NULL,                  -- _DATA
    CONSTRAINT [pk_w_userdata] PRIMARY KEY ([key], [ixs_ref])
)

Entity
namespace WebTime11.Web.ANeTCommon    
{
       public partial class W_USERDATA
       {
             private string _KEY;
             public virtual string KEY
             {
                 get
                 {
                     return this._KEY;
                 }
                 set
                 {
                     this._KEY = value;
                 }
             }
             private string _IXS_REF;
             public virtual string IXS_REF
             {
                 get
                 {
                     return this._IXS_REF;
                 }
                 set
                 {
                     this._IXS_REF = value;
                 }
             }
             private byte[] _DATA;
             public virtual byte[] DATA
             {
                 get
                 {
                     return this._DATA;
                 }
                 set
                 {
                     this._DATA = value;
                 }
 
             }
       }
}

Rlinq
<orm:class name="W_USERDATA" uniqueId="fe16e8a9-4a11-490e-be33-4a2d59c54647">
        <orm:table name="w_userdata" />
        <orm:identity>
          <orm:multiple-field>
            <orm:single-field field-name="_KEY" />
            <orm:single-field field-name="_IXS_REF" />
          </orm:multiple-field>
        </orm:identity>
        <orm:field name="_KEY" property="KEY" uniqueId="dfc7fd76-6cdf-4fe1-a393-cb8f6d672303" type="System.String">
          <orm:column name="key" sql-type="varchar" nullable="false" length="255" scale="0" primary-key="true" ado-type="Varchar" />
        </orm:field>
        <orm:field name="_IXS_REF" property="IXS_REF" uniqueId="35069e56-93fe-461e-993a-7b5838932067" type="System.String">
          <orm:column name="ixs_ref" sql-type="varchar" nullable="false" length="255" scale="0" primary-key="true" ado-type="Varchar" />
        </orm:field>
        <orm:field name="_DATA" property="DATA" uniqueId="27f456cd-ec1c-4cd2-ae91-6f3e20d69c62" type="System.Byte[]">
          <orm:column name="data" sql-type="image" nullable="true" length="0" scale="0" ado-type="LongVarBinary" />
        </orm:field>
      </orm:class>
.
.
.
 
<orm:table name="w_userdata">
        <orm:column name="key" sql-type="varchar" nullable="false" length="255" scale="0" primary-key="true" ado-type="Varchar" />
        <orm:column name="ixs_ref" sql-type="varchar" nullable="false" length="255" scale="0" primary-key="true" ado-type="Varchar" />
        <orm:column name="data" sql-type="image" nullable="true" length="0" scale="0" ado-type="LongVarBinary" />
</orm:table>

4 Answers, 1 is accepted

Sort by
0
Petr Šatka
Top achievements
Rank 1
answered on 31 May 2011, 08:11 AM
Hi Telerik.
Edit: I fixed the typo in the update code example (new byte[5]). (It has nothing to do with error in real application.)

Regards
Peter
0
Accepted
Thomas
Telerik team
answered on 02 Jun 2011, 09:58 PM
Hi Petr Šatka,

I've found and fixed the issue. The next version will contain the fix. Unfortunately, there is currently no workaround for this issue; only null values will work.

Kind regards,
Thomas
the Telerik team
Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
0
Edson
Top achievements
Rank 2
answered on 23 Dec 2011, 06:45 PM
Hi, I am using 2011 Q3 version and I am having the same problem during the Update. Is there any workaround?
Tks.

Edson.
0
Thomas
Telerik team
answered on 27 Dec 2011, 06:55 PM
Hi Edson,

can you please open a support ticket describing the exact circumstances when this happens to that we are able to reproduce the issue. (Database used, etc.)

Greetings,
Thomas
the Telerik team

Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
Development (API, general questions)
Asked by
Petr Šatka
Top achievements
Rank 1
Answers by
Petr Šatka
Top achievements
Rank 1
Thomas
Telerik team
Edson
Top achievements
Rank 2
Share this question
or