The Scenario
Currently I have a c# silverlight business application. The application is hosted in Asp.net using the ADO.Net entity framework and a domain service class to read/write to/from my sql server database.
The Setup
Client UI
In my silverlight client interface I have an autocomplete box which uses a query to get a list of items relating to the search. The query is in my domain service class and looks as follows:
public IQueryable<Status> GetStatus()
{
var q = (from job in Context.Job
select job.Status).Distinct()
.Select(deliveryState => new Status
{
DeliveryState = deliveryState,
Count = Context.Job.Count
(job => job.Status.Trim() == deliveryState.Trim())
});
q = q.Where(job => job.DeliveryState != null);
return q;
}
Code Behind
Then in my code behind for the silverlight client interface xaml page, I load the query in the contructor using the following code:
var context = dds.DomainContext as InmZenDomainContext;
statusFilterBox.ItemsSource = context.Status;
context.Load(context.GetStatusQuery(), (lo) =>
{
//just to show you how to load..
//new ErrorWindow("Loaded.." + lo.Entities.Count()).Show();
}, null);
The Issue
The issue I have is what happens now if I add another autocomplete box to my client interface, and another Get query to perform a different type of search:
public IQueryable<ShortCode> GetShortCode()
{
var q = (from job in Context.Job
select job.ShortCode).Distinct()
.Select(name => new ShortCode
{
Name = name,
Count = Context.Job.Count
(job => job.ShortCode.Trim() == name.Trim())
});
q = q.Where(job => job.Name != null);
return q;
}
The issue arises due to the fact that the "Context.Load()" function does not support loading multiple queries. Also If I try to declare to separate "Context.Load()" - Only one of them works........
How can I get around this!?!
Help greatly appreciated.