开发者

LINQ over WCF Service (DomainService)

I have a simple DomainService:

[EnableClientAccess]
public class DomainService1 : IDomainService1
{
    [Query(IsComposable = true)]
    public IEnumerable<int> GetCollection(int from, int count)
    {
        const int max = 100000;
        int[] _collection;

        _collection = new int[max];

        for (int i = 0; i < max; i++)
        {
            _collection[i] = i;
        }

        return _collection.Skip(from).Take(count);
    }
}

On client side I have generated proxy: client

I need comose LINQ query on client side and perform it on server side and throught service return query result.

When 开发者_Go百科I do:

var res1 = client.GetCollection(100, 20).Skip(5).Take(5);

than client.GetCollection(100, 20) in performed on server side and Skip(5) and Take(5) on client side.

When i do:

var res2 = client.GetCollection(100, 90000).Skip(10).Take(10);

it throw exception:

The underlying connection was closed: The connection was closed unexpectedly.

I think that this is due, that client.GetCollection(100, 90000) return large resultset.

Is a way get better information about reason why server fault? And it possible perform query from client on server? I think so, because this allows LinqToEntitiesDomainService. But i cannot use EF, because i have access only to list of object stroed in memory.

Thank you.

JPo


The exception is almost certainly due to the large dataset, so you can try upping the maximum buffer/message sizes in the <binding> config, eg:

<binding name="MyServiceBinding" maxReceivedMessageSize="6291456" maxBufferSize="6291456">
    <readerQuotas maxArrayLength="6291456" maxStringContentLength="6291456"/>
</binding>

Make sure you add those to the bindings in both the client and the server's config.

As for getting the additional client-defined parts of the query to execute on the server, you might need to make the return value an IQueryable<int> instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜