2010-10-03 6 views
6

Estoy intentando devolver una clase personalizada desde mi servicio de datos WCF. Mi clase personalizada es:No se puede devolver la clase personalizada desde WCF Data Service

[DataServiceKey("ID")] 
public class Applist { 
    public int ID { get; set; } 
    public string Name { get; set; } 
} 

mi servicio de datos se parece a:

public static void InitializeService(IDataServiceConfiguration config) 
{ 
    config.RegisterKnownType(typeof(Applist)); 
    config.SetEntitySetAccessRule("*", EntitySetRights.All); 
    config.SetServiceOperationAccessRule("GetApplications", ServiceOperationRights.AllRead); 
} 

[WebGet] 
public IQueryable<Applist> GetApplications() { 
    var result = (from p in this.CurrentDataSource.Applications 
      orderby p.ApplicationName 
      group p by p.ApplicationName into g 
      select new Applist { ID = g.Min(p => p.id), Name = g.Key }); 

    return result.AsQueryable(); 
} 

Sin embargo cuando corro el servicio, me da un error:

Request Error Request Error The server encountered an error processing the request. 
The exception message is 'Unable to load metadata for return type 
'System.Linq.IQueryable`1[ApplicationService.Applist]' of method 
'System.Linq.IQueryable`1[ApplicationService.Applist] GetApplications()' 

La misma consulta se ejecuta a la perfección bien en LINQPad.

+0

Renombrado a WCF Data Services hace un año .... –

+0

¿Si se usa WCF Data Services, con el VS 2010 y los servicios de datos ADO.Net con VS 2008 SP1 hace la diferencia ? – Ashish

+0

¿Obtuviste alguna solución para esto? – genericuser

Respuesta

Cuestiones relacionadas