Monday, 7 April 2014

SilverLight does not support the 'Edit' operation

SilverLight does not support the 'Edit' operation.
This EntitySet of Type does not support the 'Edit' operation.
Error:
This EntitySet of Type 'SLRIA.Web.MyFriend' does not support the 'Edit' operation.

Solution is.
Add below code in service.cs file.
MyFriend is ADO.net entity data model class name.
-----------------
[Update]
public void UpdateUser(MyFriend user) { }
[Delete]
public void DeleteUser(MyFriend user) { }
-----------------------------------
namespace SLRIA.Web
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.ServiceModel.DomainServices.EntityFramework;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
// Implements application logic using the FriendslistEntities context.
// TODO: Add your application logic to these methods or in additional methods.
// TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
// Also consider adding roles to restrict access as appropriate.
// [RequiresAuthentication]
[EnableClientAccess()]
public class FriendsService : LinqToEntitiesDomainService
{
// TODO:
// Consider constraining the results of your query method. If you need additional input you can
// add parameters to this method or create additional query methods with different names.
// To support paging you will need to add ordering to the 'MyFriends' query.
public IQueryable GetMyFriends()
{
return this.ObjectContext.MyFriends;
}
[Update]
public void UpdateUser(MyFriend user) { }
[Delete]
public void DeleteUser(MyFriend user) { }

}
}