OData V3 support

Posts   
 
    
DJ
User
Posts: 2
Joined: 14-Jan-2013
# Posted on: 17-Jan-2013 08:26:07   

Hi LLBLgen

I'am trying to create a OData WCF service based on V3. I become a compiler problem.

Based on the manual "LLBLGen Pro - generated code- WCF Data Services support" I have created the WCF service. The only change i have made is using a "WCF Data Service (for OData V3)" in stead of "WCF Data Service". I have done that because i will use OData V3.

When compiling the code the next error occure: _The type 'System.Data.Services.DataService`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Services, Version=4.0.0.0, Culture=neutral, _ Currently the version of this assembly in my project is 5.0.0.0.

My question is how can LLBLgen support OData V3?

In a previous console project i have made sure that the base code generated with LLBLGen is working correct. By the code generation we used the adapeter model. I am using LLBLGen 3.5. with msvc 2010 with as target .net4

NMackay
User
Posts: 138
Joined: 31-Oct-2011
# Posted on: 17-Jan-2013 11:31:32   

DJ wrote:

Hi LLBLgen

I'am trying to create a OData WCF service based on V3. I become a compiler problem.

Based on the manual "LLBLGen Pro - generated code- WCF Data Services support" I have created the WCF service. The only change i have made is using a "WCF Data Service (for OData V3)" in stead of "WCF Data Service". I have done that because i will use OData V3.

When compiling the code the next error occure: _The type 'System.Data.Services.DataService`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Services, Version=4.0.0.0, Culture=neutral, _ Currently the version of this assembly in my project is 5.0.0.0.

My question is how can LLBLgen support OData V3?

In a previous console project i have made sure that the base code generated with LLBLGen is working correct. By the code generation we used the adapeter model. I am using LLBLGen 3.5. with msvc 2010 with as target .net4

I think the short answer is no, it might be in V4 but the LLBLGen guys will confirm this.

http://www.llblgen.com/documentation/3.5/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_wcfdataservices.htm

Ef4 has the same limitation I think.

I recently finished a mobile app project for iOS and Android, LLBLGen was used for the ORM layer. I started of using oData but you have to use JSONP requests for that and it has severe limitations. If it's for a Java client I'd recommend a WCF Rest API or Web API approach and return DTOs/POCO classes serialized as json, works much better.

There's an even quicker approach I found on Frans asp.net blog

http://weblogs.asp.net/fbouma/archive/2012/11/04/llblgen-pro-and-json-serialization.aspx

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 17-Jan-2013 14:02:52   

We'll build v4's odata services dll against the WCF Data Services dll available from nuget, which supports Odata v3.

You can compile v3.5's odata services code against this dll as well, manually: - get the runtime library sourcecode from the Extras section in the customer area - load the OdataSupportClasses project into vs.net - instead of referencing System.Data.Services from the .NET 4/4.5 distribution, reference the one available on nuget. - make sure you reference the linqsupportclasses and ormsupportclasses dlls in the vs.net project

This should compile fine. It now supports odata v3. We don't do this to v3.5 code today because it will break applications. It's unfortunate MS is this sloppy with distributing .net frameworks but alas, what can you do simple_smile

If you want to live on the edge, there's a commented out check in the code as well for inheritance hierarchies, which you can enable. Not tested but odata v3 should support it OK.

Hopefully this gives you what you're after simple_smile

Norman's advice in his post is also good advice: it might very well be that you need something else than OData.

Frans Bouma | Lead developer LLBLGen Pro
NMackay
User
Posts: 138
Joined: 31-Oct-2011
# Posted on: 17-Jan-2013 14:16:39   

That's customer service for you simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 17-Jan-2013 14:35:19   

NMackay wrote:

That's customer service for you simple_smile

Thanks simple_smile We do our best simple_smile

Frans Bouma | Lead developer LLBLGen Pro
DJ
User
Posts: 2
Joined: 14-Jan-2013
# Posted on: 18-Jan-2013 10:16:04   

Thanks, for your advice.

I compiled the LLBLGen OData as described and we have a OData v3 server.

Now we can look furhter.

DJ

scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 08-Mar-2013 02:19:55   

I recently finished a mobile app project for iOS and Android, LLBLGen was used for the ORM layer. I started of using oData but you have to use JSONP requests for that and it has severe limitations. If it's for a Java client I'd recommend a WCF Rest API or Web API approach and return DTOs/POCO classes serialized as json, works much better.

There's an even quicker approach I found on Frans asp.net blog

http://weblogs.asp.net/fbouma/archive/2012/11/04/llblgen-pro-and-json-serialization.aspx

Norman, could you speak more specifically to the limitations you encountered with ODATA/JSONP? I'm working on a very similiar project and am trying to make some decisions about SOA. (And also looking at ServiceStack.net).

NMackay
User
Posts: 138
Joined: 31-Oct-2011
# Posted on: 08-Mar-2013 10:10:39   

scotru wrote:

I recently finished a mobile app project for iOS and Android, LLBLGen was used for the ORM layer. I started of using oData but you have to use JSONP requests for that and it has severe limitations. If it's for a Java client I'd recommend a WCF Rest API or Web API approach and return DTOs/POCO classes serialized as json, works much better.

There's an even quicker approach I found on Frans asp.net blog

http://weblogs.asp.net/fbouma/archive/2012/11/04/llblgen-pro-and-json-serialization.aspx

Norman, could you speak more specifically to the limitations you encountered with ODATA/JSONP? I'm working on a very similiar project and am trying to make some decisions about SOA. (And also looking at ServiceStack.net).

Hi Scott,

Biggest issue we encountered with JSONP is error handling (or lack of), as our authentication service and data service were on different ports the browser effectively treats the calls as cross-domain. JSONP gets round this but essentially it won't return anything if your WCF service throws an exception like a 403 if your security key is invalid, This Ajax call show's what kind of error trapping you might want:


$.ajax({
                type: "POST",
                url: "https://www.myservice.com:8090/Myservice.svc/GetCustomer",
                contentType: "application/json",
                beforeSend: function (xhr) { 
                    xhr.setRequestHeader('srv-authorization', localStorage.getItem('MyEncryptedKey)); 
                },
                data: JSON.stringify(e.dataItem.MyCustomerId),
                dataType: "json",
                cache: false,
                success: function(msg) {
                    custfetchResponse(msg);
                },
                statusCode: {
                    400: function(jxhr, textStatus, errorThrown) {
                        app.hideLoading();
                        ModalViewNotify(APP_MSG2, "Data Service Error");
                    },
                    403: function() {
                        app.hideLoading();
                        ModalViewNotify("Your security key has expired or is invalid", "Security Error");
                        endSession();
                    }
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    app.hideLoading();
                    ModalViewNotify("My Data service is not available at present, please try later", "Server Error");   
                }
            });     

With a JSONP call you can't trap these errors effectively, you have to do a hack that sets a timeout and trap that but you won't know why your service failed.

All modern web browsers use CORS, all the Android, iOS and Blackberry webkit browsers do and Chrome and they are the browser we support. Firefox does after a certain version and IE of course has it's own non standard approach but most modern browsers send a 200 (OPTIONS) request to the WCF service and you have to handle that.

CORS is the moderm approach so if I was starting a new project I wouldn't consider JSONP, also I'm not entirely sure where MS is going with oData, they dropped the Rest API and rolled it into WebAPI even though it's in the .NET4 framework. Also on a 3G connection or lower you have to really consider the amount of data your returning, we just found the performance of the Rest API far better (on UK mobile networks anyway).

We support native iOS, native Android and webkit browser, we've found this approach to be very robust and you still get data back even when you have a weak mobile signal, the less data you have to send over the wire the better IMO.

If your getting data from data service you don't host or control then JSONP is an option as you won't have any control over CORS domain issues.

If you want to chat about this I'm on LinkedIn, just send me an invite.

http://www.linkedin.com/pub/norman-mackay/0/22b/56

Cheers, Norman.