Tuesday, September 23, 2008

ADO.NET Data Services + Oracle

Wow - this is wicked cool stuff.

ADO.NET Data Services allow you to expose IQueryable objects as RESTful endpoints in ATOM, POX, and JSON. Here's my brain dump of how cool this can be used for RAD purposes...

ADO.NET Data Services is being plugged as just a endpoint for ADO.NET Entities, and thus just SQL Server's LINQ to SQL implementation. Microsoft themselves are doing most of that damage - but I want to point out how it's much bigger than that!

If you're like me, you have the pleasure (yes, pleasure) of working with Oracle instead of SQL Server. Many times this leaves you feeling high and dry with all this cool new LINQ stuff. There is no realy good LINQ to Oracle implementation out there - but the team at NHibernate has come to the rescue.

NHibernate is a .NET port of the years old Java Hibernate project - providing ORM for your software. The importance of this framework in the RAD world is big - it allows you to very easily map a database to objects.

LINQ to NHibernate is almost a year old now, and is in the process of being implemented in the main trunk of NHibernate (currently it's there, but throws a NotImplementedException after mocking you by showing you the SQL it knows that it should use). However, in the NContrib trunk, I have found a quite functional version of LINQ to NHibernate!

Why do I bring this up? Because some kind people in the project have even gone so far as to implement the System.Data.Services.IUpdateable interface within the LINQ.NHibernate project. This means fully functional ADO.NET Data Services for your Oracle database.

With only a couple lines of code, you can expose your NHibernate objects as queryable JSON, ATOM, POX RESTful services. Simply extend NHibernateContext, provide a ProvideSession() implementation, and expose public IQueryable properties on your object. Use this class as the type parameter of a new System.Data.Services.DataService class, and you'll be all set.

ADO.NET data services provides the RESTful interface which is flexible enough to pass pagnation, ordering, filtering, etc straight through the web layer to the database layer. So a javascript request for:

http://server/someobject?$filter=someid eq '1'&$orderby=somefield

produces SQL sent straight to Oracle of

select *
from someobject
where someid = 1
order by somefield

It's also fully updatable (through the IUpdateable implementation) which means that POST, PUT, DELETE requests work in a similar fashion.  It provides it in a JSON format, allowing you to use your database tables as javascript collections.... wow... Again, the RAD implications are huge.

The only issue that I have is with performance - NHibernate doesn't seem to stream resultsets (instead building the object array all at once), and the wordy ATOM/JSON formats don't suit some applications. ADO.NET Data Services is NOT pluggable with custom serialization - I've decompiled and searched for an entry point for literally DAYS.

One other point to make, is that referencing these new data services from VS2008 SP1 provides you with a client side LINQ object which translates linq queries to filtered HTTP requests (as in the filter/order/etc format above, which then translates to SQL... So, cool.

I'd provide some detailed examples and implementations - but that'd ruin all the fun ;)

29 comments:

Chris Hemsworth said...

The article is so informative. This is more helpful for our
best software testing training in chennai
best software testing training institute in chennai with placement
software testing training
courses

software testing training and placement
software testing training online
software testing class
software testing classes in chennai
best software testing courses in chennai
automation testing courses in chennai
Thanks for sharing.

mano karan said...

Nice post.. Really you are done a wonderful job. Thanks for sharing such wonderful information with us. Please keep on updating...
Best C & C++ Course Training Institute in kanchipuram|

sandhiya said...

Very nice post here and thanks for it .I always like and such a super blog of these post.Excellent and very cool idea and great blog of different kinds of the valuable information's.
Best Tally Erp 9.0 Course Training Institute in kanchipuram|

karthik said...

Interesting post!!! Thanks for posting such a useful information. I wish to read your upcoming post to enhance my skill set and keep blogging.
Best Tally Erp 9.0 Course Training Institute in kanchipuram|

rajinikumar said...

This is excellent information. It is amazing and wonderful to visit your

site.Thanks for sharing this information, this is useful to me.
Best Selenium

Automation Course Training Institute in kanchipuram
|

bharathidasan said...

I have read your blog. Good and more information useful for me, Thanks for sharing this information keep it up....
Best Dot Net Course Training Institute in kanchipuram|

sandhiya said...

Really it was an awesome blog...very interesting to read..You have provided an nice information....Thanks for sharing..
Best Hardware & Networking Course Training Institute in kanchipuram|

karthik said...

Thanks for sharing in this blog...its very useful for us...keep on going...
Best MS Office Course Training Institute in kanchipuram|

mano karan said...

Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it.
Best PCB (Printed Circuit Board) Course Training Institute in kanchipuram|

Renuka capure said...

very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing…
No:1
Python Training Academy in kanchipuram

Renuka capure said...

very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing…
No:1
Python Training Academy in kanchipuram

Renuka capure said...

very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing…
No:1
Python Training Academy in kanchipuram

Renuka capure said...

very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing…
No:1
Python Training Academy in kanchipuram

Renuka capure said...

very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing…
No:1
Python Training Academy in kanchipuram

roshlin said...

Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it.
No:1 Tally Training Academy in Kanchipuram

rajinikumar said...

Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
Best PCB (Printed Circuit Board) Course Training Institute in kanchipuram|

monika said...

Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it.
No:1 Hardware and Networking Training Academy in Kanchipuram

sandhiya said...

Awesome post. Really you are shared very informative information... Thank you for sharing. Keep on updating...
Best AWS (Advanced Amazon Web Services) Course Training Institute in kanchipuram|

karthik said...

Great post..Its very useful for me to understand the information..Keep on blogging..
Best Software Testing Course Training Institute in kanchipuram|

mano karan said...

I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
Best Cloud Computing Course Training Institute in kanchipuram|

janaki devi said...

Nice..You have clearly explained about the conept..Its very useful for me to
undertand..Keep on sharing..

No:1Tally Training Academy in Kanchipuram







janaki devi said...

Nice..You have clearly explained about the conept..Its very useful for me to
undertand..Keep on sharing..

No:1Tally Training Academy in Kanchipuram







bharathidasan said...

I found some useful information in your blog, it was awesome to read, thanks for sharing this great information to my vision, keep sharing.
Best Graphic Designing Course Training Institute in kanchipuram|

sandhiya said...

Marvelous and fascinating information.Thanks for this greatful blog. keep your blog updated.
Best Hardware & Networking Course Training Institute in kanchipuram|

Malar said...

This is really awesome. Full of knowledge and latest information.Thanks for sharing.
Best JAVA / J2EE / J2ME Course Training Institute in kanchipuram|

suresh said...

great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
No:1 Best EEE Project Center in kanchipuram|

bharathidasan said...

really you have posted an informative blog. it will be really helpful to many peoples. thank you for sharing this blog. so keep on sharing such kind of useful blogs.
No:1 Best NS2 (Network Simulator) Project Center in kanchipuram|

sandhiya said...

very usefull informatation.and iam expecting more posts like this please keep updating us....
No:1 Best Android Project Center in kanchipuram|

LHi Lab said...

Its a great pleasure reading your post. Its full of information I am looking for and I love to post a comment. Get the best and detailed conversion optimization services Minneapolis for more information.