title: Accessing data set over WCF without serializing the entire thing?
body: <p>I'm very new at WCF (and .NET in general), so I apologize if this is common knowledge.</p>
  
  <p>I'm designing a WCF solution (currently using Entity Framework to access the database).  I want to grab a (possibly very large) set of data from the database, and return it to the client, but I don't want to serialize the entire set of data over the wire all at once, due to performance concerns.  </p>
  
  <p>I'd like to operation to return some sort of object to the client that represents the resulting data and I'd like to deal with that data on the client, being able to navigate through it backwards and forwards and retrieve the actual data over the wire as needed.</p>
  
  <p>I don't want to write a lot client code to individually find out what rows meet my search criteria, then make separate calls to get each record if I can help it.  I'm trying to keep the client as simple as possible.</p>
  
  <p>Ideally,  I'd like to write the client code similar to something like the below pseudocode:</p>
  
  <pre><code>Reference1.Service1Client MyService = new Reference1.Service1Client("Service1");
  
  DelayedDataSet&lt;MyRecordType&gt; MyResultSet = MyService.GetAllCustomers();
  
  MyResultSet.First();
  
  while (!MyResultSet.Eof)
  {
      Console.Writeline(MyResultSet.CurrentRecord().CUSTFNAME + " " + MyResultSet.CurrentRecord().CUSTLNAME);
      Console.Writeline("Press Enter to see the next customer");
      Console.Readline();
      MyResultSet.Next();
  }
  </code></pre>
  
  <p>Of course, DelayedDataSet is something I just made up, and I'm hoping something like it exists in .NET.</p>
  
  <p>The call to MyService.GetAllCustomers() would return this DelayedDataSet object, with would not actually contain the actual records.  The actual data wouldn't come over the wire until CurrentRecord() is called.  Next() and Previous() would simply update a cursor on the server side to point to the appropriate record.  I don't want the client to have any direct visibility to the database or Entity Framework.</p>
  
  <p>I'm guessing that the way I wrote the code probably won't work over WCF, and that the functions like CurrentRecord(), Next(), First(), etc. would have to be separate service contract operations.  I guess I'm just looking for a way to do this without having to write all my own code to cache the results on the server, somehow persist the data sets server side, write all the retrieval and navigation code in my service library, etc.  I'm hoping most of this is already done for me.</p>
  
  <p>It seems like this would be a very commonly needed function.  So, does something like this exist?</p>
  
  <p>-Joe</p>