0 Replies - 501 Views - Last Post: 23 August 2012 - 02:28 AM Rate Topic: -----

#1 idq  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 19-September 11

Why is my service operation not found?

Posted 23 August 2012 - 02:28 AM

Hello,

Im trying to create a simple WCF Data Service that shall expose a service operation. But when I try to run it I get a ArgumentException "The given name 'TestOperation' was not found in the service operations." at the
config.SetServiceOperationAccessRule("TestOperation", ServiceOperationRights.AllRead);
Am I missing something?

public class TestService : DataService<DataProvider>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);

            config.SetServiceOperationAccessRule("TestOperation", ServiceOperationRights.AllRead);

            config.DataServicebehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    }



public class DataProvider
    {
        List<TestEntity> _entities = new List<TestEntity>();

        public DataProvider()
        {
            _entities.Add(new TestEntity{ ID = 1, Name = "Test" });
        }

        [WebGet]
        public IQueryable<ProductFamily> TestOperation()
        {
            return _entities.AsQueryable<TestEntity>();
        }
    }



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



Is This A Good Question/Topic? 0
  • +

Page 1 of 1