Because the documentation on ADO.NET ObjectSpaces is pretty thin, I will start posting all things that I find out about ObjectSpaces, especially if undocumented at this point in time. Scott S Sikora posted a question in news:microsoft.public.objectspaces relating to spans for ObjectQueries. He has multiple relations in his object hierarchy and wonders how to retrieve the child objects from both relations.
Well, spans contain comma separated members that list the names of the properties for the parent members of the relationships. The list must not end with a (trailing) comma, or you will get a QueryException. For example: suppose your parent class Person has two one-to-one relationships to child objects called theManager and theSupervisor of type Manager and Supervisor respectively. Querying for both of these would become:
SqlConnection con = new SqlConnection(“DATA SOURCE=(local);” +
“INTEGRATED SECURITY=SSPI;INITIAL CATALOG=PersonsDatabase”);
ObjectSpace os = new ObjectSpace(“MappingSchema.xml”, con);
Person p = null;
p = (Person)os.GetObject(typeof(Person), “ID=1”,
catch (ObjectException ex)
if (ex.InnerException != null)
Console.WriteLine(p.theManager.Name + ” ” + p.theSupervisor.Name);
I’ve bolded and underlined the span for multiple relationships.