This is a migrated thread and some comments may be shown as answers.
Showing join data in Gridview
1 Answer 21 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Burhan Eyimaya
Top achievements
Rank 1
Burhan Eyimaya asked on 19 Jan 2010, 09:32 AM
Hi,

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.

ArrayList

 

IService1.GetPatientStudies()

 

 

{

 

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)

 

 

    itemList.Add(data);

  

 

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)

 

  {

ServiceReference1.

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

 

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

 

 

webService.GetPatientStudiesAsync();

}

 

 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.

Thanks,
Burhan

 

 

1 Answer, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 21 Jan 2010, 06:37 PM
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,
Petar
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.
Tags
Databases and Data Types
Asked by
Burhan Eyimaya
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Share this question
or