locked
stored procedure and OData RRS feed

  • Question

  • I have a simple stored procedure that returns a few columns, the WCF Data Services returns the data, however it does not return the data in OData format (ATOM).

    I have the following code in the service, what else do I need to add to the WebGet?

      public class Case : DataService<CaseEntities>
      {
        public static void InitializeService(DataServiceConfiguration config)
        {
          config.SetEntitySetAccessRule("*", EntitySetRights.All);
          config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
          config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
        [WebGet]
        public IQueryable<ChangeQueue> GetQueue()
        {
         return CurrentDataSource.GetCases().AsQueryable();
        }
      }
    
    

    Haroon
    Friday, February 25, 2011 4:16 AM

Answers

All replies

  • You must make sure ChangeQueue is an EntityType, not a complex type. With EF it's a little hard because you need to have maps between CSDL and SSDL (meaning, you need an underlying table/defining query to be an entity type). 

    Regards,

    PQ


    Peter Q. http://blogs.msdn.com/peter_qian
    Friday, February 25, 2011 6:13 AM
    Answerer
  • Peter,

    are you suggesting creating an "dummy" SQL table on the database so that an entity type get mapped and populate on the [webget] method. 

    Is there a way to doctor up the xml (csdl,ssdl and msdl) without physically creating a real table in the database?


    Haroon
    Friday, February 25, 2011 6:29 AM
  • You can create an SSDL Element with DefiningQuery:

    http://msdn.microsoft.com/en-us/library/bb738450.aspx


    Peter Q. http://blogs.msdn.com/peter_qian
    • Marked as answer by Haroon Said Sunday, February 27, 2011 7:52 AM
    Friday, February 25, 2011 6:27 PM
    Answerer
  • A bit primitive approach - but works
    Haroon
    Sunday, February 27, 2011 7:52 AM