This question is locked. New answers and comments are not allowed.
Hi,
I have a couple of persistence enabled objects, one of which has a list of the other as it's content.
e.g.
I used forward mapping to create a MySql database.
Then I can happily create a Container class with a list of ListedClass inside it, put some values into theText of each ListedClass object and write it to the database using scope.Add, and I can confirm that it's all there in the database as expected. Even when I retrieve the objects using the same scope as they were written with, all of the data comes back fine.
But if I create a new scope and use that to read back the Container class, I still get a list of ListedClass objects, and there are the right number of them, but the string field inside each one is set to null. Of course the same thing happens if I start the app again and just try to read the values. Strangely enough, after writing a Container class, if I retrieve all of the Container classes in the database, the one I just wrote has the correct data, and all of the pre-existing ones have null strings.
Is there something obvious that I'm doing wrong? I know the write to the database is correct because I can do queries outside of OpenAccess ORM and the data is fine.
I've tried doing things like setting the fetchplan for the scope to include "All", but that didn't help.
I've also tried manually refreshing the ListedClass objects after retrieving them, but that doesn't help either.
I've also set the scope's transaction properties to AutomaticBegin = true;
The code I'm using to retrieve the data is:
Can someone tell me what I'm doing wrong?
Thanks,
Marcus.
I have a couple of persistence enabled objects, one of which has a list of the other as it's content.
e.g.
[Telerik.OpenAccess.Persistent()] |
public class ListedClass |
{ |
public string theText; |
} |
[Telerik.OpenAccess.Persistent()] |
public class Container |
{ |
public IList<ListedClass> fields; |
} |
I used forward mapping to create a MySql database.
Then I can happily create a Container class with a list of ListedClass inside it, put some values into theText of each ListedClass object and write it to the database using scope.Add, and I can confirm that it's all there in the database as expected. Even when I retrieve the objects using the same scope as they were written with, all of the data comes back fine.
But if I create a new scope and use that to read back the Container class, I still get a list of ListedClass objects, and there are the right number of them, but the string field inside each one is set to null. Of course the same thing happens if I start the app again and just try to read the values. Strangely enough, after writing a Container class, if I retrieve all of the Container classes in the database, the one I just wrote has the correct data, and all of the pre-existing ones have null strings.
Is there something obvious that I'm doing wrong? I know the write to the database is correct because I can do queries outside of OpenAccess ORM and the data is fine.
I've tried doing things like setting the fetchplan for the scope to include "All", but that didn't help.
I've also tried manually refreshing the ListedClass objects after retrieving them, but that doesn't help either.
I've also set the scope's transaction properties to AutomaticBegin = true;
The code I'm using to retrieve the data is:
var resultobj = from c in scope.Extent<Container>() select c; |
return resultobj.ToList<Container>(); |
Can someone tell me what I'm doing wrong?
Thanks,
Marcus.