I'm new to working with WCF and i'm struggling to understand whats happening.
I'm trying to retrieve data from my service, which in turn grabs it from the database. To simplify things I wanted to return an object containing the data so that it could just be used immediatly within the UWP app. However, I'm running into the following error when I try to consume the service:
Cannot implicitly convert type 'MBCMobile.ServiceReference1.TaskBreakdown_GetDataResponse' to 'MBCMobile.ServiceReference1.JobTestObject'
The following code is what I'm using:
[ServiceContract]
public interface IService1
{
[OperationContract]
JobTestObject TaskBreakdown_GetData(int task, int appliance, int job);
}
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class Service1 : IService1
{
public JobTestObject TaskBreakdown_GetData(int task, int appliance, int job)
{
JobTestObject jobData = data.TaskBreakdown_GetData(task, appliance, job); //object returned from sql query
return jobData;
}
}
To consume my service im using the following:
private async void GetString()
{
ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
JobTestObject datalist = await service.TaskBreakdown_GetDataAsync(6153, 18876, 18111);
}
JobTestObject
has the same format in both the service and the UWP app. The service version literally exists as a collection of get/set methods and nothing else. The app version has additional methods, but the exact same get/set methods. I've tried using ServiceReference1.JobTestObject
instead to see if that helps but to no avail. I expect that it might be a little naive of me to think an object can be passed to the client this way.
I also tried just returning a list of strings and got a similar error.
I've managed fine in the past with retrieving single values from the service, but now that I want to get multiple values at once I can't understand what I'm doing wrong. Sadly most of the solutions I've found don't relate to UWP apps
Update: As requested
[DataContract]
public class JobTestObject
{
int appliance_id, manu_id, model_id, landlord_app, applianceType_id,
[DataMember]
public int ApplianceType { get { return applianceType_id; } set { applianceType_id = value; } }
[DataMember]
public int Appliance_ID { get { return appliance_id; } set { appliance_id = value; } }
[DataMember]
public int ApplianceManufacturer { get { return manu_id; } set { manu_id = value; } }
[DataMember]
public int ApplianceModel { get { return model_id; } set { model_id = value; } }
}