Actually, regardless of whether a service is written (your suggestion) or whether a remote-aware DataAccessAdapter is written (my suggestion) or a combination of both, there is still the issue of serialization performance when remoting is involved in any way.
This is not an LLBLGen issue of course and I see that your implementation of ISerializable reduces the data down to the bare minimum required to work for all serialization cases.
However, in a remoting case, it will generally boil down to moving an EntityCollection from one machine to another (a single entity could be seen as a collection of one object to keep things simple) with the minimum amount of data for this specific case.
That means that some of the data currently serialized will (may?) be redundant - saved fields, predicate factory and that kind of thing. (Actually, since these are likely to be null they make take up very little space anyway)
Let me give you some test figures:
These are using a standard DataAccessAdapter to a SQL Server database (which is on a poorly-specced development server
) and then use a binary formatter to serialize to a memory stream to check the size and serialization time:
I run a query that returns 536 ship entities:
It takes 1.078 seconds and serializes to 610,061 bytes in 0.28 seconds.
I then run a query with a prefetch path and a sub prefetch path returning 536 ships, 13,376 Voyages and 17,924 Port Calls:
It can get all of these in just 12 seconds which is amazingly fast!!
However it takes over 13.5 minutes to serialize them to a staggering 37MB!!!
not to mention the CPU time involved.
This is just serialization one-way of course, that 37MB would then have to be transmitted over the network and then deserialized and then require possibly more time to overlay onto existing entities (if there are any)
This test query may be atypical of general use of course but getting 31,846 entities from a database to the client computer can be done in 12 seconds but involving a remote layer will take 27+ minutes.
I see that other posts have been querying the same issue and showing that .NET serialization does an awful lot of work (retrieving that same object data dozens of times etc) that is redundant for the above scenario.
It seems to be me that there may be scope to transparently (without altering the IDataAccessAdapter interface but maybe adding an IRemoteDataAccessAdapter?) split out the database retrieval and entity population elements:- the database retrieval to be done either on the client or via a remote machine, and using an efficient point-to-point method to relay that data optimally, with the entity population always being done on the destination (client) machine.
If all is done locally then the effect would be negligible or a NOP but for remoting we may see just the data itself doing one additional network hop - total of 24 seconds plus a little overhead?? which would blow away any other way of doing remote entites (ie wrapping ADO 2.0 datasets/tables in binary mode)
Cheers
Simon
PS I know you are very busy with v2.0 now but maybe 2.1? Or I might have a look at this if you could give me any guidance.