Get values from my service into ODataService

4 posts, 0 answers
  1. Kenneth
    Kenneth avatar
    27 posts
    Member since:
    Nov 2010

    Posted 18 Jun 2012 Link to this post

    Hi
    I have built a WCF Data service and I just want to ask what I should write to be able to work with it In a ODataService.

    Here’s my WCF dataservice:

    using System;
    using System.Data.Objects;
    using System.Data.Services;
    using System.Data.Services.Common;
    using System.Linq;
    using System.ServiceModel.Web;
    using DataServicesJSONP;
     
    namespace BD2.Web.Services.WebService
    {
        [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
        [JSONPSupportBehavior]
        public class Room : DataService<ObjectContext>
        {   
            public static void InitializeService(DataServiceConfiguration config)
            {
                config.SetServiceOperationAccessRule("GetTime", ServiceOperationRights.All);
                config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            }
     
            [WebGet]
            public string GetTime()
            {
                return DateTime.Now.ToLongTimeString();
            }
        }
    }

    (The [JSONPSupportBehavior] is a script to remove dollar-signs from the jsonp that gives troubles with ODataservice. I got it from: http://stackoverflow.com/questions/2983078/cant-get-the-jsonp-working-with-wcf-data-services).
    (I use ObjectContxt because I get data from Entity FrameWork Code FIrst. I got help for building it from: http://blogs.msdn.com/b/writingdata_services/archive/2012/05/05/10175174.aspx).

     

     I would like to read in the string from GetTime(). How should my ODataService then be like?:

    <telerik:RadODataDataSource runat="server" ID="RadODataDataSource1">
               <Transport>
                   <Read Url="http://localhost:52878/Services/WebService/Room.svc/" />
               </Transport>
               <Schema>
                   <telerik:DataModel ModelID="GetTime" Set="???????" />
               </Schema>
    </telerik:RadODataDataSource>

    Thanks :o)

     

  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 19 Jun 2012 Link to this post

    Hello Kenneth,

    As you know the RadODataData source is really a new component and we are still gathering feedback on what features do you want to see in it. Unfortunately, we don't yet support web methods.

    The ODataSource expects that in the service there are end points (like Products from the Northwind database) that expose Product (if we refer to the example) entities in IQueryable format.

    You may want to check this excellent video of Shawn Wldermuth demonstrating how to create such OData services. Another video showing how to create OData service from entity framework data models can be found here. Does these make sense in your scenario? If not we will be glad to hear any feedback on what piece of functionality you need in the data source so that it fits your scenario.

    Regards,
    Genady Sergeev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kenneth
    Kenneth avatar
    27 posts
    Member since:
    Nov 2010

    Posted 19 Jun 2012 Link to this post

    Thank you for your answer Genady

    I have seen the videos and they work very fine with how to build a svc-file to use with Telerik ODataService.

    I will think about what you write about making endpoints - perhaps making the :
    public string GetTime()
    into:
    public IQueryable<someObject> GetTime()

    I need a way to procces the data in my svc-file before I expose the data. Perghaps I will go in depth with Telerik XMLHttp instead and see if that’s possible. Wish me luck :o)

    Thanks again.

  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 21 Jun 2012 Link to this post

    Hi Kenneth,

    Indeed, I believe that RadODataDataSource won't be very helpful in this scenario. Don't hesitate to drop us a line should you face any issues using RadXmlHttpPanel. :)


    Kind regards,
    Genady Sergeev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top