0
votes

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??

1
Are you exposing GetGenres as a DomainService, or just a plain WCF service? - JMarsch
Domain Service operation only. - user695663
Is GetGenres() being interpreted as a Query? I've never tried to return a list from a DomainService -- always either IEnumerable<Entity> or IQueryable<Entity>. Maybe GetGenres() is being generated as an Invoke instead of a Query. - JMarsch
Pasted my DomainServiceOperation code. - user695663

1 Answers

0
votes

The problem is that you have GetGenres marked as an Invoke operation. If you mark it as a query operation and rebuild, I think that you will be in good shape.