0

I am planning a WCF service to return lists, data, all the usual things.

Now I saw on here ages ago that as of .NET 4.5 you could pass lambda expressions or filters to WCF (I also saw something in a pluralsight video somewhere) that allowed you to write something along the lines of

IQuerable<string> GetInfo();
// or
List<string> GetInfo(Expression predicate);

Instead of

GetInfo(int page, int resultsPerPage, bool sortAsc, string sortColumn);

However, as I'm reading around I see lots of conflicting (and old) information saying that this isnt possible. Is it then at all possible to filter WCF results before they are returned via some linq or lambda expression?

Update

I have implemented a Service (WCF not WCF Data Services) like so, and I get the expected result. Is the client actually passing the query to the web service or is it being rendered client side?

public class Service1 : IService1
{
    public IQueryable<string> DoWork()
    {
        List<string> strings = new List<string>();
        for (char c = 'a'; c < 'z'; c++)
        {
            strings.Add(c.ToString());
        }

        return strings.AsQueryable();
    }
}

Client:

Service1 s = new Service1();
var results = s.DoWork();
var results1 = results.Where(str => str == "a"); // works
Chris
  • 26,744
  • 48
  • 193
  • 345
  • I would like to know more about it as well. I assume consumer also should have IQuerable implemented. How a Java based consumer will achieve that? – PradeepGB Aug 12 '13 at 11:13
  • Found a similar accepted question here : http://stackoverflow.com/questions/18143181/c-sharp-how-to-serialize-system-linq-expressions – PradeepGB Aug 12 '13 at 11:31

1 Answers1

0

Looks like you need WCF Data Services.

Dennis
  • 37,026
  • 10
  • 82
  • 150