I have a DAL where I have Entity Framework to expose entities. These entities are used in a WCF Service project and exposed to the client.
I consume these entities in the Silverlight web project via service reference. Then I am using a RIA domain service for code sharing. But I get the following error while trying to load operation:
DomainContext context= new DomainContext();
LoadOperation<Genre> lo = context.Load<Genre>(context.GetGenres());
GetGenres() is a Domain Service operation where it loads all Genres.
[Invoke]
public IEnumerable<Genre> GetGenres()
{
return proxy.GetGenres(); //proxy is wcf proxy.
}
This Query returns a List. Where Genre is the DataContract i got from the WCFServiceReference.
Actual Error:
The type 'SL.Web.ServiceReference.Genre' cannot be used as type parameter 'TEntity' in the generic type or method 'System.ServiceModel.DomainServices.Client.DomainContext.Load(System.ServiceModel.DomainServices.Client.EntityQuery)'. There is no implicit reference conversion from 'SL.Web.ChinookServiceReference.Genre' to 'System.ServiceModel.DomainServices.Client.Entity'.
Question is:
Can I do this way or should I have a custom class in Silverlight that maps to the WCF service datacontract and share the custom entity between the Silverlight client and Web project?
Is there a way to share entities from a service reference between Web and client using a DomainService??