Reputation: 8008
I'm trying to get a list of entities from a WCF service, the problem I'm experiencing is that we have some bad latency on the network and so the data takes a considerable amount of time to get to my client. The idea I have is to find a way to get the first 1000 and just push those to the UI while I'm waiting for the next ones to arrive.
I guess it would be like paging but I just want to page the full set in the WCF layer rather that get one page at a time from the db
Cheers
Upvotes: 7
Views: 2759
Reputation: 8008
In the end as I'm using tcpTransport for my communication, I ended using duplex channels to do what I needed.
What I did is just change my current SearchMethod that was returning a big list to void. Inside this method I get my data from the DB, chunk it and send it to the client via a callback operation
Upvotes: 0
Reputation: 81660
WCF looks at the message at its entirety before handing it to higher levels. Hence your data needs to arrive in full and usual WCF contracts will not work.
However, you can use streaming with WCF. This allows for the payload to be read gradually from the stream and be passed to the higher levels. In order to get it working you need to:
This will more complex that WCF straight out of the box but achieves what you need.
Upvotes: 6
Reputation: 2259
You can always split your service interface into two methods. For example, instead of:
List<T> GetItems()
You can have:
int GetItemCount()
List<T> GetItems(int start, int maxSize)
So that you can implement paging manually.
Upvotes: 3