I need to serialize a .NET table adapter. Serializing a data adapter and the data set is not a problem but i seem unable to serialize the table adapter. Looking at the type its typically specific to whatever you name it..like if i create a Invoice Table Adapter..the type will be InvoiceTableAdapter and its base type is component. This does not give me an easy type to work from like the sql data adapter which is relatively simple to serialize. Also, i need to be able to serialize it and deserialize it without having to include the dll it came from when i deserialize it. The only dlls available on when deserializing will be standard .NET dlls.
-
You've got up to 4 Sql strings, the rest isn't worth/viable to save. – H H Sep 24 '11 at 08:41
-
@Henk indeed, I've never really understood why they get created as types. – Marc Gravell Sep 24 '11 at 08:58
-
@Marc: the generated versions are 'strongly typed' but that won't work for the OP. – H H Sep 24 '11 at 09:03
1 Answers
Also, i need to be able to serialize it and deserialize it without having to include the dll it came from when i deserialize it.
If you are using BinaryFormatter
(which I don't recommend, by the way), then no: you can't do that. That isn't how BinaryFormatter
works. It expects to recreate exactly what was serialized, which demands the same dlls.
If you are using any other serializer, it makes perhaps even less sense; you should be serializing *data, really. Not plumbing details like adapters.
In all seriousness, I think you need to reconsider your design here. Why are you trying to serialize adapters, for example? What would that even mean? It might, for example, make sense to write a DTO that represents the data you need to construct a vanilla SqlDataAdapter
.

- 1,026,079
- 266
- 2,566
- 2,900
-
If i could i would. This is a problem with a report layout file by a 3rd party vendor. If i cant figure out how to serialize and deserialize the report layout, i will be stuck using dlls that will be stored in database and requested by a windows service. Storing the layout is a waste as a dll, having to compile a layout every time it changes...for alot of reasons, it just makes it hard to manage actually. It would be much better off if i could just store the layout as a standalone xml file that gets put into the db. – leifre Sep 26 '11 at 07:06
-
The report vendor offers a custom serialization/deserialization method off of their report objects. The only part i cant successfully serialize/deserialize of the report layout is the table adapter. Normally i would agree with you about serializing a table adapter but in this case, its necessary so that i can get away from using dlls...its a report layout..it seriously doesnt need to be a dll ;) – leifre Sep 26 '11 at 07:06
-
@leifre exactly - so can't it take a SqlDataAdapter with a few properties set? Does it really have to be an OrderDataAdapter (or whatever)? – Marc Gravell Sep 26 '11 at 07:15
-
Ill try serializing the data adapter and see if it will take just that and report back later. – leifre Sep 26 '11 at 08:02
-
I did end up finding a way to serialize the table adapter. I basically created a dataadapter and put it into the table adapter and it works. Basically, i custom serialize the command text, command type, and parameters. The dataset can be automatically serialized. I store all of that and then create a new data adapter using this information on deserialization. Sorry for the delay in my response...i forgot to update :) – leifre Nov 29 '11 at 06:42