I am wondering if there are any alternatives to using the Expand key word when performing an LINQ to ADO.net Data Services query. The expand method does get me the data I am interested in, but it requires me to know all of the sub-objects that I am going to be working with in advance. My absolute preference would be that those sub-objects would be lazy loaded for me when I access them, but this doesn't look to be an option (I could add this lazy loading to the get on that sub-object property, but it gets wiped out when I do an update of the data service reference).
Does anyone have any suggestions/best practices/alternatives for this situation? Thanks.
===== Example Code using Member that has a MailingAddress =====
Works:
var me = (from m in ctx.Member.Expand("MailingAddress")
where m.MemberID == 10000
select m).First();
MessageBox.Show(me.MailingAddress.Street);
Would Prefer (would really like if this then went and loaded the MailingAddress)
var me = (from m in ctx.Member
where m.MemberID == 10000
select m).First();
MessageBox.Show(me.MailingAddress.Street);
Or at least (note: something similar to this, with MailingAddressReference, works on the server side if I do so as LINQ to Entities in a Service Operation)
var me = (from m in ctx.Member
where m.MemberID == 10000
select m).First();
if (!(me.MailingAddress.IsLoaded())) me.MailingAddress.Load()
MessageBox.Show(me.MailingAddress.Street);