Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a broad question about Web Services and SOA. I have a database that contains data I would like to expose for reading (just reading, no inserts or updates). Is it best to expose the data as a class or is it best to expose the information as a datareader?
Posted

It must be a class. Client applications should not be knowing anything about database.
 
Share this answer
 
Comments
css-bp 13-Jan-11 18:11pm    
Thank you
It' considered "best practice" to expose only the data that is relevant for the client. It's usually a good idea not to expose the data source (database) directly.

If this is an inhouse, intranett application, it can make sense to access the database server directly. It's probably cheaper to develop.

Regards
Espen Harlinn
 
Share this answer
 
v2
Comments
dan!sh 13-Jan-11 18:19pm    
Since OP has mentioned WCF, TCP binding would provide similar experience, isn't it? That will provide more flexibility in case similar thing is to be made available to outer world as well.
Espen Harlinn 13-Jan-11 18:28pm    
You're right, but better always comes at a cost - we all know there is no such thing as a free lunch :) Cutting out the middle tier usually makes development cheaper. Standard Binary Serialization over TCP/IP still has a horrible performance overhead. Take a look at this article: http://www.codeproject.com/KB/dotnet/FastSerializer.aspx.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900