Silverlight + RIA: task editing object

I have a Silverlight 4 application with EntityFramework as a data layer.

There are two objects: Customer and Products. When I get the client from the database, the related products are also read, as I added the associated "Include" attribute to the client metadata and the Include method is called in the request request:

public IQueryable<customer> GetCustomerSetById(int customerId)
{
    return this.ObjectContext.CustomerSet
        .Include(o => o.Products)
        .Where(o => o.Id = customerId);
}

The problem is that when I change any property in the client product, I get this exception:

This EntitySet type "MyApp.Web.Models.Product" does not support the "Change" operation.

But everything works if I directly read customer products, for example. not through the customer object (CustomerContext), but through the product one (ProductContext).

Also in the product object is the property IsReadOnly = true.

UPDATE:

CUD, Insert, Update Delete. , , .

?

+3
4

RIA + EF, , , . , , EF T4 . .

+2

, , . :

public void UpdateProduct(Product product)
{
    ObjectContext.Products.AttachAsModified(product, ChangeSet.GetOriginal(product));
}
0

RIA Services EntitySet does not support Modify operation

Since the above solutions do not seem to help use this:

Domain Service Wizard

This wizard should look at your entity and generate appropriate CRUD operations. If you cannot update your entities, you will have another problem.

0
source

Did you try to move Include to the end?

Return this.ObjectContext.CustomerSet
        .Include(o => o.Products)
        .Where(o => o.Id = customerId);

May be:

Return (from o in this.ObjectContext.CustomerSet
        where o.Id = customerId
        select o).Include("Products");
0
source

All Articles