I'm using dotConnect with RIA to enable my Silverlight application to access my Oracle database.
On the client side, to get parent entities to load with the query that retrieves the child I have found I have to do the following to get things working.
In my child metadata class, use the include attribute:-
Code: Select all
[MetadataTypeAttribute(typeof(FOCUS_POINT.FOCUS_POINTMetadata))]
public partial class FOCUS_POINT
{
internal sealed class FOCUS_POINTMetadata
{
[Include]
public ANSWER_TYPES ANSWER_TYPES;
...
Code: Select all
public IQueryable GetFOCUS_POINTForHeaderVersion(int headerVersion)
{
var res = this.ObjectContext.FOCUS_POINT.Where(fp =>
fp.FOCUS_P_HD_VER.FOCUS_P_HD_VER_ID == headerVersion).OrderBy(fp => fp.SORT_ORDER);
foreach (var item in res)
{
item.ANSWER_TYPESReference.Load();
}
return res;
}
Code: Select all
var loader3 = domainContext.Load(domainContext.GetFOCUS_POINTForHeaderVersionQuery(headerVersionId), false);
loader3.Completed += new EventHandler(loader3_Completed);
}
void loader3_Completed(object sender, EventArgs e)
{
foreach (var currentFocusPoint in domainContext.FOCUS_POINTs)
{
MessageBox.Show(currentFocusPoint.ANSWER_TYPES == null ? "NULL" : "OK");
}
}
Now I was wondering if there was a way without iterating through calling Load on each entity that is to be returned?
I read that you could use the Include method for LINQ to Entities as per this link:-
http://social.msdn.microsoft.com/Forums ... d163481f53
Trying this shows "NULL" in the above MessageBox code though. Thanks very much for your help in advance!