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

Array Null until loaded

1 Answer 44 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David Hollins
Top achievements
Rank 1
David Hollins asked on 24 May 2010, 05:33 PM
I have an object which contains a struct that encapsulates a double[].  The double[] is stored as a blob and all seems to save correctly.  When retrieving the values though, the double[] is null unless I wait for a second before accessing its values.  I am able to get it working if I walk through it in the debugger and slow it down manually but when running it outside of the debugger the array is just null.

Is this a timing issue of some sorts?  Can I check to see of the object is still loading and wait, etc.

Some other things to note as well, if I browse into the object in the debugger and access the variable itself it seems to load the value BUT if I access the value while browsing by going through the access method (the property method) then it is null.

Any help is appreciated!

Thanks,
David Hollins

1 Answer, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 25 May 2010, 02:50 PM
Hello David,

I'm sure there is another reason but the 1 second delay. I'm guessing that the debugger variable visualizer steps in here, evaluates the content of the array and that's why it is visible after a short period of time in the debugger. But why is it not visible in a run outside of the debugger? Please note, that OpenAccess uses a technique called 'lazy loading' where not all fields are populated immediately, but upon access to them. Most likely in your case there is an issue with the struct that gets embedded in the class, however. This is when a struct field is returned from a property, the values in the struct must be copied as the returned struct value is actually a copy of the original (embedded in the class). Therefore it can make a difference if you write

MyInstance.StructFieldProp.ArrayProp

or have a method double[] MyClass::Read() { return this.StructFieldProp.ArrayProp; }

In the first case a copy of the whole struct is required logically, in the second case it is not. User defined structs are really non-trivial to understand and although OpenAccess supports them, my advice is not to use them in the persistent model as they tend to create behaviors which are strange on the first sight.

All the best,
Thomas
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Data Access Free Edition
Asked by
David Hollins
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or