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

subtable not retrievable from persistent class in a list

1 Answer 41 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeremiah
Top achievements
Rank 1
Jeremiah asked on 10 Mar 2009, 09:22 PM
I have a persistant class BasicProfile which contains a property HomeLocation.
The HomeLocation refers to a Location table.

Now I have a method:
 public void retrieveBasicProfileMatches(
            ref string query, 
            ref List<BasicProfile> searchResults,
            ref IObjectScope objectScope)

The List is populated within the method.
After the call, I iterate through the list with a foreach but I get a null reference when trying to reference my HomeLocation data.
However, if I load a single BasicProfile using the id retrieved from the list, then the HomeLocation data is available:

foreach (BasicProfile b in searchResults)
{
    ...
   // something = b.HomeLocation.Province + ", " + b.HomeLocation.CountryCode;
   // bombs... but the following works
   BasicProfile redundant = load(b.MemberId, objectScope).
   something = redundant.HomeLocation.Province + ", " + b.HomeLocation.CountryCode; //works
...
}

Any ideas?  note the objectScope is in scope the whole time.

1 Answer, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 12 Mar 2009, 12:25 PM
Hi Jeremiah,
we tried to reproduce your case. We used the order table from the northwind database. The order has a reference to employee.
static void Main(string[] args) 
        { 
            IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope(); 
            string Query = "Select * From OrderExtent"
            List<Order> myOrderList = new List<Order>(); 
            RetrieveOrders(ref Query,ref myOrderList,ref scope); 
            foreach (Order ord in myOrderList) 
            { 
                Console.WriteLine(ord.Employee.FirstName); 
                Console.ReadKey(); 
            } 
             
       } 
        public static void RetrieveOrders(ref string Query, ref List<Order> OrderList, ref IObjectScope scope) 
        { 
 
            Query<Order> result = scope.GetOqlQuery<Order>(Query); 
            QueryResultList<Order> myResult = result.ExecuteList(); 
            OrderList = myResult.ToList(); 
        } 
The following piece of code retrieves all orders and prints the names of the employees who carried the order.This code works in our case. In order to aid you with your problem would it be possible for you to recreate the problem in a simple application and send it to us.

Sincerely yours,
PetarP
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Jeremiah
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Share this question
or