Solved

Out of ideas, need help getting data back from a RIA Domain Service

Posted on 2010-11-30
3
314 Views
Last Modified: 2012-05-10
New to RIA Domain Services and everthing I've found so far says it should work but I can't get it to work and was hoping for some guidance.

I have a Database entity and a Domain Service tied to it.  If I drag a grid onto my web page and associate an entity, it populates the grid fine.  If in my Domain Service (I created a custom method that does a join) it doesn't return data (even though it does in a separate c# windows app).  

Custom Domain Service Method w/joins:
public IQueryable<Time> GetTimeWithAppointments()
{
    try
    {
        var query = from t in this.ObjectContext.Times
                    join a in this.ObjectContext.Appointments on t.ID equals a.TimeID into times
                    from a in times.Where(item => item.TimeID == t.ID).DefaultIfEmpty()
                    join c in this.ObjectContext.ClientInfos on a.ClientID equals c.ID into clients
                    from c in clients.Where(client => client.ID == a.ClientID).DefaultIfEmpty()
                    select new { t.Time1, a.Subject, c.FirstName, c.LastName };

        return query as ObjectQuery<Time>;
    }
    catch (Exception ex)
    {
        return null;
    }
}

If I change the above return code it will return just fine and populate the grid:
return this.ObjectContext.Appointments;

And the strange thing is, the Domain Service NEVER returns anything when called like this:
SchedulingDomainContext context = new SchedulingDomainContext();

var query = from a in context.GetTimeWithAppointmentsByDateQuery()
            where a.Subject != null
            select a;

var loadOperation = context.Load<Web.Appointment>(query, MyCallBack, null);//context.GetAppointmentsQuery());
loadOperation.Completed += new EventHandler(loadOption_Completed);

foreach (Web.Appointment appt in context.Appointments)
{
    int x = 6;
}

And neither of the callbacks get called.  I must be forgetting something, I'm totally confused.  If some other code is needed please let me know.  I've been banging my head against the wall for a day now.
0
Comment
Question by:ichikuma
3 Comments
 
LVL 21

Accepted Solution

by:
tovvenki earned 250 total points
Comment Utility
Hi,
Check in your silverlight client whether are you using the proper domaincontext. I have faced similar issue in not getting the data to be deleted by calling the delete and in the end I found that it was because of using a wrong domaincontext.

Thanks and regards,
Venki
0
 

Author Comment

by:ichikuma
Comment Utility
Thanks Venki, I just found the issue, I wasn't handling the Complete on the LoadObject.

Thanks again for the suggestion.
0
 
LVL 5

Assisted Solution

by:KiasChaos83
KiasChaos83 earned 250 total points
Comment Utility
Ichikuma, what you've stated gives me the impression that you're not using databinding to its full potential. There are a lot of great databinding features in Silverlight. If your DomainContext does a query and hence updates any of its Entities internally, it will trigger all controls that are databound to the list.

If you haven't databound the controls (including the window/childwindow) then you're missing out. If you have databound the controls and it's not updating then you need to ensure that you are keeping the list in an array type that implements INotifyChanged.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial will show you how to add an attribute to an XML (http://en.wikipedia.org/wiki/XML) stream returned from a Windows Communication Foundation (http://en.wikipedia.org/wiki/Windows_Communication_Foundation) (WCF) Web Service.  Some knowled…
In previous Articles, we have discussed how we can upload a file using .asmx web service and isolated storage space. Here, in continuation to the topic, I am going to discuss how we can use WCF for the same purpose. Steps: 1.Create the silverli…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now