Showing join data in Gridview

2 posts, 0 answers
  1. Burhan Eyimaya
    Burhan Eyimaya avatar
    6 posts
    Member since:
    Jan 2010

    Posted 19 Jan 2010 Link to this post


    I am trying to build a silverlight application that shows some data on a gridview.
    I have built persistent classes using Open Access ORM and I am writing a WCF
    like below.








    IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope();




    var query = (from p in scope.Extent<Patient>()




    join s in scope.Extent<Study>()




    on p.Pk equals s.PatientFk




    select new { PatName = p.PatName, StudyDesc = s.StudyDesc });

    ArrayList itemList = new ArrayList();




    foreach (var data in query)






    return itemList;



    It simply takes fields from patients and studies tables.
    And in MainPage.xaml.cs I have written

     void MainPage_Loaded(object sender, RoutedEventArgs e)




     Service1Client webService = new DatabaseTest.ServiceReference1.Service1Client();


    webService.GetPatientStudiesCompleted += new EventHandler<DatabaseTest.ServiceReference1.GetPatientStudiesCompletedEventArgs>(webService_GetPatientStudiesCompleted);






     void webService_GetPatientStudiesCompleted(object sender, DatabaseTest.ServiceReference1.GetPatientStudiesCompletedEventArgs e)




    testGridView.ItemsSource = e.Result;


    But it doesn't work a CommunicationException occurs. In the message it says "The remote server returned an error: NotFound."

    I couldn't find the problem. Is there a problem in the way I am building the array list.
    Please help.




  2. PetarP
    PetarP avatar
    754 posts

    Posted 21 Jan 2010 Link to this post

    Hi Burhan Eyimaya,

    The problem is that you are putting a projection in a not strongly typed collection. This is impossible to be transported via a WCF service as it requires a data contract type. You will need to create a class that  contains all fields from your projection and mark it with the DataContract attribute. The class will serve as a transporter object for the result of the query. After you have done that you will be able to alter your query to something similar to this:
    var query = (from p in scope.Extent<Patient>()
    join s in scope.Extent<Study>()
    on p.Pk equals s.PatientFk
    select new TransporterClass { PatName = p.PatName, StudyDesc = s.StudyDesc });
    Do not forget to change the signature of the GetPatientStudies method so it returns a generic collection of TransporterClass objects. You may need to recreate the service references afterwards.
    This should fix your problem. Please do get back to us if you face any further difficulties.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
Back to Top