user1809104
user1809104

Reputation: 717

Exposing nHibernate data via a web API. Advice

I'm working on a side project where ive decided to expose data with a web api so that when i create the mobile app version of the project I can consume the web services instead of connecting straight to the database.

My questions are: Is this recommended? Will it reduce performance?

I've noticed that now whenever I add new functionality to the NhibernateRepository class I need to create the web api version exposing that data - this takes a little more time.

Also, what about when it comes to more complex queries, shall I just retrieve some of the data straight from the nhibernate queries and some from the web api?

Upvotes: 0

Views: 368

Answers (1)

pedrommuller
pedrommuller

Reputation: 16066

Well "pulling data" directly from your database server it's a terrible idea, managing your connections / repositories / dao or whatever methodology your using from your mobile app would be a more challenging rather than just talking to a rest service.

some advantages of a rest service:

  • you can put any front end on top of that, that means a web (javascript front end), mobile, tablet , etc.
  • you are reusing your code
  • you are using a thin server approach
  • you are decoupling your code
  • you can send json over the wire, your mobile app will be back-end agnostic, so you'll be able to switch your REST service implementation if you want (moving to another programming language) without refactoring you mobile app

take a look to a architecture design named API first probably by reading that you'll get a bigger picture of what I'm talking about.

performance?

well that's a little bit broad assumption, I wouldn't be too worried about that if you have a good / solid architecture design over a decent relationship between traffic / hardware you will be fine.

I'd suggest for you to take a look on servicestack which is a very nice framework out there with a very nice performance 3.9 is free and from 4.0 is a paid version either way using web API or Servicestack are good options the best that you feel more comfortable.

Upvotes: 1

Related Questions