This is a migrated thread and some comments may be shown as answers.

Get values from my service into ODataService

3 Answers 84 Views
ODataDataSource
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 2
Kenneth asked on 18 Jun 2012, 06:24 AM

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)

 

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 19 Jun 2012, 07:57 AM
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.
0
Kenneth
Top achievements
Rank 2
answered on 19 Jun 2012, 08:17 AM

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.

0
Genady Sergeev
Telerik team
answered on 21 Jun 2012, 11:37 AM
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.
Tags
ODataDataSource
Asked by
Kenneth
Top achievements
Rank 2
Answers by
Genady Sergeev
Telerik team
Kenneth
Top achievements
Rank 2
Share this question
or