About

ProLinq.Wcf allows the use of IQueryable interface in WCF web services.

Limitations

The following constraints must be followed:
  • .NET client.
  • Shared service contract via .NET assembly.
  • Communication through the WCF Channel class.
  • Only types accessible in both client and server can be used in queries.

Installation

Server

Use one of the following methods:
  • WCF service factory
Configure your service to use ProLinq.Wcf.QueryableServiceHostFactory.
<%@ ServiceHost Language="C#" Debug="true" Service="ProLinq.Wcf.Sample.Service.SampleService" Factory="ProLinq.Wcf.QueryableServiceHostFactory" CodeBehind="SampleService.svc.cs" %>
  • WCF behavior:
Add behavior extension to your web.config file:
  <system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="queryableBehavior" type="ProLinq.Wcf.Configuration.QueryableBehaviorElement, ProLinq.Wcf" />

Then add the behavior:
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <queryableBehavior />

Client

Create and configure the channel factory and channel:
var channelFactory = new QueryableChannelFactory<ISampleService>(new BasicHttpBinding());
var channel = channelFactory.CreateChannel(new EndpointAddress("http://localhost:61077/SampleService.svc"));		

You can also use CreateQueryableChannel extension method on any existing ChannelFactory.

Use

Just write it as you would with any other IQueryable:
var c = channel.GetProducts().Count();

Last edited Mar 10, 2013 at 3:00 PM by DGolubets, version 3

Comments

No comments yet.