Reputation: 543
I am trying to use a dataContext to populate a comboxbox but always got nothing:
EntityQuery<Tests> testQ = myDomainContext.GetTestQuery().Where(t => t == 5);
LoadOperation<Tests> loadOp = myDomainContext.Load(testQ)
comboxBoxTest.ItemSource = loadOp.Entities.Select(t => t.Name).Distinct().ToList();
Can someone tell me what is wrong here?
Upvotes: 0
Views: 144
Reputation: 6260
As you may know mostly all operations in RIA
are asynch. And you should be aware of this while executing queries.
You have to use callback methods (@Zabavsky's answer has good ones) for such reasons.
Also I slightly recommend you to use MVVM
pattern instead of code-behind messing. This will make your code and logic cleaner.
Upvotes: 1
Reputation: 13640
You probably don't load the entities. Try
EntityQuery<Tests> testQ = myDomainContext.GetTestQuery().Where(t => t == 5);
LoadOperation<Tests> loadOp = myDomainContext.Load(testQ);
loadOp.Completed += (o, e) =>
{
comboxBoxTest.ItemSource = loadOp.Entities.Select(t => t.Name).Distinct().ToList();
};
Or
myDomainContext.Load(testQ, new Action<LoadOperation<Tests>>(result =>
{
comboxBoxTest.ItemSource = result.Entities.Select(t => t.Name).Distinct().ToList();
}), null);
Upvotes: 1