![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| ||||
| ||||
|
|
The idea being that these would be generic methods allowing the client to pass a DataSet object to the server to have one of it's tables filled or to send updates back to the server. |
|
It seems like there's actually a fair amount of work involved in order to write the generic UpdateData method though - I have to build up a DataAdapter, set the TableMappings and the FieldMappings and finally build the Update, Insert and Delete statements (all of which I was just going to generate automatically - for example, to do an update I'd do "Update [All fields except the PK] WHERE PK = [Original PK]" - in my case if I want to do anything fancy then I'll typically do it in the triggers for the table/view that I'm updating in the actual databases themselves, so no need to do anything but plain jane default stuff in the insert/update/delete statements in the .NET remoting server). |
|
1. Is there anything I should know about why using DataSets + Remoting might be a bad idea? |
|
2. Presuming it's not such a bad idea as all that (it seems like the docs for .NET encourage using these in remoting situations at least) does anyone know of examples or tutorials or even just passing conversations/blogs anywhere that discuss more specifically sending DataSet updates back to a remoting server and handling these? |
#3
| ||||||
| ||||||
|
|
I've put together a basic server and client in remoting. In order to pass data around I presumed you'd use the detached objects like DataSet, DataTable and DataRow so I figured I'd define a DataSet class in an assembly that was shared by the client/server (along with the interfaces for the server) and then add a couple of methods: Fill(ref DataSet aDataSet, string aTableName); UpdateData(DataSet aDataSet); |
|
The idea being that these would be generic methods allowing the client to pass a DataSet object to the server to have one of it's tables filled or to send updates back to the server. It seems like there's actually a fair amount of work involved in order to write the generic UpdateData method though - I have to build up a DataAdapter, set the TableMappings and the FieldMappings and finally build the Update, Insert and Delete statements (all of which I was just going to generate automatically - for example, to do an update I'd do "Update [All fields except the PK] WHERE PK = [Original PK]" - in my case if I want to do anything fancy then I'll typically do it in the triggers for the table/view that I'm updating in the actual databases themselves, so no need to do anything but plain jane default stuff in the insert/update/delete statements in the .NET remoting server). |
|
Then I got to thinking, this is ridiculous - surely someone has bumped into this problem before me so I went scouring the internet for all and any posts I could find relating to remoting and datasets. Remarkably I came back with very little and certainly nothing that discussed sending updates back to the server or handling these. I did find the odd post from folks that suggested DataSets + Remoting was a bad idea, with various others fervently replying that they agreed, but they didn't go into any details as to why this might be the case. Perhaps it was for performance reasons in which case maybe simply serializing the datasets in binary format rather than XML would help or using something like GenuineChannels might do the trick. |
|
So, a couple of questions: 1. Is there anything I should know about why using DataSets + Remoting might be a bad idea? |
|
2. Presuming it's not such a bad idea as all that (it seems like the docs for .NET encourage using these in remoting situations at least) does anyone know of examples or tutorials or even just passing conversations/blogs anywhere that discuss more specifically sending DataSet updates back to a remoting server and handling these? |
|
Any help appreciated. Best Regards, James Crosswell Microforge.net LLC http://www.microforge.net |
#4
| ||||||||||
| ||||||||||
|
|
Is there a reason you like to do this? ADO.NET can be used to update a remote database. |
|
It seems like there's actually a fair amount of work involved in order to write the generic UpdateData method though - I have to build up a DataAdapter, set the TableMappings and the FieldMappings and finally build the Update, Insert and Delete statements (all of which I was just Absolutely, writing such a layer is not trival... You're better off using an ORM mapper for this type of work - like LLBLGen Pro. LLBLGen Pro has a dynamic SQL engine which you can leverage for this type of stuff. Other popular ORM mappers include Codesmith and NHibernate. |
|
You'll also have to build a robust security layer since you're exposing the entire database. |
|
1. Is there anything I should know about why using DataSets + Remoting might be a bad idea? Datasets and remoting are not inherently bad - but they should be used in moderation. Sending too much data across the wire (in your case entire tables) could quickly swamp network resources. |
|
Also, since datasets are disconnected, you'll have to reconcile changes - so perhaps it's best sending as little data as possible to client. |
|
If you want to send table dumps across the network, there are better protocols out there. Perhaps dump the raw CSV, or the database's native features like Bulk Updates, DTS or SQL Server Integration Server. |
|
Also from a SOA/tier design perspective, clients who use your generic database server will need to have intimate knowledge of the DB schema. |
|
In that case, why not connect directly to the database with enterprise manager or ADO.NET - you're sort of reinventing the wheel? |
|
exposing database tables to end users (developers?) who may not know the database well, you should expose specific function calls like in a web service. For example: ListUser, AddUser, DeleteUser, SaveUser, etc. |
|
Sending datasets is nothing magical in remoting ... but I think where you're having trouble is in your generic data layer? The problem you seem to be having is how to build the generic connectors required to access a table in a generic fashion? If that's the case - that is more of which how to implement your data access layer than a remoting problem? Remoting datasets should serialize fine ... so you should be able to get the dataset as an object on both sides of the connection. |
#5
| |||
| |||
|
|
Actually, it is bad idea. You can't assume it is a good idea. |
#6
| |||
| |||
|
|
msgroup wrote: Actually, it is bad idea. You can't assume it is a good idea. pff. I've been building distributed applications that work and perform |
#7
| |||
| |||
|
|
btw: sorry if the pff seemed like it was directed at you - it was more a pff of frustration. I appreciate your having taken the time to respond and your comments I'm just sure there must be a way to do this that doesn't involve writing 100 different methods for my remoting service which all look almost identical. |
#8
| |||
| |||
|
|
James Crosswell <james (AT) microforge (DOT) net> wrote in news:O4PA$9zWHHA.488 @TK2MSFTNGP06.phx.gbl: btw: sorry if the pff seemed like it was directed at you - it was more a pff of frustration. I appreciate your having taken the time to respond and your comments I'm just sure there must be a way to do this that doesn't involve writing 100 different methods for my remoting service which all look almost identical. Well it's Wednesday, we're 1/2 way towards the weekend :-) I'm not sure if Datasets are the best method to do what you want to do... how about creating a set of Data Transfer Objects which inherit from a base class? Then in your method you would pass: Public Function Update(ByVal DTO as BaseDTO) as Boolean |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |