This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Do you guys have any plans to integrate with WCF Data Services similar to this [1]. Having a LINQ provider seems to be more than half the battle. Being able to have OData endpoints with Oracle connectivity would be big for us. This seems like a void left by Entity Framework not supporting Oracle.
|
|
|
LightSpeed 3 does actually include an ADO.NET Data Services provider, but we found some usability issues with it and have therefore chosen not to promote it. I believe that ADO.NET Data Services is OData-compliant, though I haven't been tracking the OData stuff closely enough to be certain. If the ADO.NET Data Services provider sounds like it might address your requirement, let me know and I'll post some info about how to use it. |
|
|
I hope you guys work for a OData implementation... |
|
|
Hi Ivan, I am really intersted in hooking up ADO.Net Data Services (OData). Can you ellaborate on your provider and how to use it? Thanks. |
|
|
There are two steps to building an ADO.NET Data Service using LightSpeed. The first is to derive a strong-typed unit of work class (analogous to a LINQ to SQL DataContext) from Mindscape.LightSpeed.DataServices.DataServiceUnitOfWork. If you are using the designer then it will do this automatically if the project containing the model references System.Data.Services.dll. The second is to create a WCF data service using this strong-typed class. To do this, derive from System.Data.Services.DataService<TUnitOfWork>, where TUnitOfWork is the strong-typed unit of work class you created in step one. Override CreateDataSource to call LightSpeedContext.CreateUnitOfWork. Your service will look something like this: public class TestDataService : DataService<TestUnitOfWork> Now you can surface this data service via a WCF endpoint in the usual way. Now for the bad news. The reason we don't talk about this much is that the .NET 3.5 version of datasvcutil isn't able to generate client-side proxies for LightSpeed services. This appears to be because the LightSpeed entities inherit from a generic base class (Entity<TId>), and either ADO.NET Data Services is representing that base class badly in the metadata document or datasvcutil is handling it badly. We haven't yet tested this with .NET 4.0 so it may work better now. If it doesn't, though, you'll have to create your client data context and proxy classes by hand. This isn't too difficult, just rather dreary. Your entity proxies will look like this: [DataServiceKey("Id")] Note the entity proxies must have the same names as the entity classes and must therefore be kept in a different namespace and/or assembly. Your client data context will look like this: public class TestDataServiceContext : DataServiceContext Obviously the Comment class here is the client proxy Comment class, not the server Comment entity class. To reiterate we have not yet tested this feature with .NET 4.0: I seem to recall the Astoria team made some significant changes in the 4.0 iteration so we would welcome any feedback on improvements or issues you run into. |
|
|
Thanks Ivan, that acutally a lot less work than i thought it was going to be :) Hand crafting the client proxies isnt the end of the universe either. Ill try it out in .NEt 4.0 and see if the dataservices proxy generator has gotten any smarter. Thanks! |
|
|
Hi Ivan, I'm not having any luck getting this working. I have created the data service and I can get a list of the Entities no problem (via browser) i.e. http://localhost:12345/ServiceName.svc/. Querying any deeper and I get HTTP 500 errors i.e. http://localhost:12345/ServiceName.svc/Posts I've attached the model I am using & the .svc.cs file i am trying this out with. I tried targeting 3.5 as well as 4.0 with the same outcome. Any pointers? Thx.
|
|
|
Your code looks correct, though without a buildable project it's hard to be sure. My first suspicion would be a connectivity or query error, though for me these give an XML error document rather than a plain 500. Some tips for diagnostics: * Turn on verbose errors (config.UseVerboseErrors = true;). * Run the service under the debugger and look for first-chance exceptions when opening the Posts page. * Turn on SQL logging (LightSpeedContext.Logger = new TraceLogger();) and verify that the SQL looks correct. * Open the generated StoreModel.cs file and verify that StoreModelUnitOfWork inherits from DataServiceUnitOfWork. |
|
|
I noticed in another thread that you have an entity called User. This doesn't appear in the posted model, but if it's part of the actual model then that could be part of the problem because User is a reserved word in SQL Server and will cause SQL errors if not quoted. So it's probably worth adding: QuoteIdentifiers = true to your LightSpeedContext. This probably won't solve your 500 problem, but it should help to avoid nasty surprises down the line. |
|
|
Hi Ivan, Thanks for the pointers. I narrowed it down and got it resolved. Basically my DB (SQL Server File MDB) was wired up correctly in my Test project (and all my tests using the LightSpeed Entities were working as expected).... but in my Web Project with the WCF Data Service it wasn't using the correct Connection String. Also thanks for the pointer on the User issue. You saw in the model i moved to Person to get around this ... but thanks for the Tip about Quoted Identifiers... nice. Thx again. -Lounge. |
|
|
Hello Ivan, How has this changed (if at all) with .NET 4.0 and LightSpeed 4.0? Also, since this post is the top Google hit for "Lightspeed OData" I'll leave a pointer to the WCF Web Api. While it's not full OData, it does turn any method returning IQueryable into an OData data source. If you update the Lightspeed/MVC tutorial for MVC3/LightSpeed 4, maybe toss this in (there's sufficient IQueryable support now, right?) http://wcf.codeplex.com/wikipage?title=Getting%20started:%20Building%20a%20simple%20web%20api
|
|
|
We didn't make any changes to our OData/Data Services support in LightSpeed 4. We do have an item on the backlog to revisit this in the light of the .NET 4 improvements. Jeremy (our WCF guru) thinks that the WCF Web API "does make it easier for people when they are building a service layer (rather than just using DataServices)" so it sounds like that could be the way to go but we haven't looked into formally documenting integration because "it’s a little unclear where that’s heading longer term at the moment since it’s just a Codeplex project for now." I'll see if Jeremy has time to write a blog post about it, or if you are willing to share any experiences using LightSpeed with the WCF Web API then that would be awesome! |
|