I'm using ADO.Net Data Services (Astoria) in Silverlight 3 and I want to delay loading properties on an entity until after the initial load. However, when I'm ready to load them I'd like to batch the load requests together.
// this is what I want to avoid
var c = (from c in ctx.Customers.Expand("Address,Phone,Email")
where c.Id = 12
select c).Take(1) as DataServiceQuery<Customer>;
I've gotten this far:
// I can do this instead
var c = (from c in ctx.Customers // .Expand("Address,Phone,Email")
where c.Id = 12
select c).Take(1) as DataServiceQuery<Customer>;
c.BeginExecute(CustomerCallback, objState);
...
// Later, when I want properties, I need to do this
ctx.BeginLoadProperty(c, "Address", AddressCallback, objState);
ctx.BeginLoadProperty(c, "Phone", PhoneCallback, objState);
ctx.BeginLoadProperty(c, "Email", EmailCallback, objState);
However, I can't figure how how to get a DataServiceRequest object for a load property request to pass to BeginExecuteBatch. Is it possible to issue these requests (and potentially others that aren't associated with the customer property load) in the same batch by getting a DataServiceQuery?
Something like this:
// c is the customer from the above load
ctx.BeginExecuteBatch(BatchCallback, objState, new []{
ctx.GetLoadQuery(c, "Address"),
ctx.GetLoadQuery(c, "Phone"),
ctx.GetLoadQuery(c, "Email"),
GetOtherNonPropertyQuery()
});