I'm trying to expose a web service which returns a list of objects from a method in my project. It's an IList and I believe I need to convert it to a List type so it can be serialised for XML but I can't quite figure out how.
Error:
Cannot serialize member NAA.Data.Profile.Application of type System.Collections.Generic.ICollection`1[[NAA.Data.Application, NAA.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface.
Web service code:
public class NAAWebService : System.Web.Services.WebService
{
private NAA.Services.IService.IProfileService _applicationService;
public NAAWebService()
{
_applicationService = new NAA.Services.Service.ProfileService();
}
[WebMethod]
public List<NAA.Data.Application> GetApplicationList(int id)
{
return _applicationService.GetApplicationList().ToList();
}
And the method in my project:
public IList<Application> GetApplicationList()
{
IQueryable<Application> _applications;
_applications = from appl
in _context.Application
select appl;
return _applications.ToList<Application>();
}
Any help at all would be much appreciated! Thanks