I am trying to work with a RIA Domain Service as if it's a WCF service (which technically it is)
There seems to be key elements "missing" from the generated proxy client. For example associated object properties.
For simplicity here's an example of two classes:
public class Person
{
[Key]
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
[Include]
[Association("Person_Hobbies", "Id", "Person_Id")]
[Composition]
public IEnumerable<Hobby> Hobbies { get; set; }
}
public class Hobby
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public int Person_Id { get; set; }
}
and in the Domain Service we could return people and their hobbies as:
public IQueryable<Person> GetPeople()
{
var peopleList = new[] {
new Person { Id = 1, FirstName = "Fred", LastName = "Flintstone", Hobbies = new List<Hobby>() { new Hobby { Id = 1, Name="Reading", Person_Id=1 },
new Hobby { Id = 2, Name="Biking", Person_Id=1}, }},
new Person { Id = 2, FirstName = "Barnie", LastName = "Rubble", Hobbies = new List<Hobby>() { new Hobby { Id = 3, Name="Skiing", Person_Id=2 },
new Hobby { Id = 4, Name="Rock Climbing", Person_Id=2} } },
};
return peopleList.AsQueryable<Person>();
}
I have verified that this works exactly as expected, between Silverlight and the DomainService.
However in the Console App that also references this RIA Domain Service the generated Person class does not have a Hobbies property (as it does in the Silverlight client).
It is true that when I call GetPeople I get RootResults (people) and IncludedResults (Hobbies) and I can "join" the two together. So I can live without the Hobbies property
The difficulty is in preparing an array of ChangeSetEntry --- How do i send up to the service both a person and their hobbies from the console App? In Silverlight I create a new Person, add hobbies to the Hobbies property and Add the Person to DomainContext and SubmitChanges. Behind the scenes RIA Server (either at the client or the server I'm not sure) sorts it out.
I'm struggling with the linkage of person to hobbies in the array of ChangeSetEntry objects.