17

Func is a serializable class, but yet when I try to pass it as a parameter through a service. I'm told it "isn't a known type". I've tried the solutions here to no avail.

Many thanks out there...

KevDog
  • 5,763
  • 9
  • 42
  • 73

2 Answers2

11

No, basically. You can't pass an Expression either, since it talks to MemberInfo nodes. Your best bet is a string representation of the predicate.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
9

There's work happening to enable it. Check out the Expression Tree Serialization project on the MSDN Code Gallery.

tom redfern
  • 30,562
  • 14
  • 91
  • 126
Matt Hamilton
  • 200,371
  • 61
  • 386
  • 320
  • 2
    That's really scary. Expressions are great for application code, but there are some serious security implications for service code. – Michael Meadows Feb 19 '09 at 21:54
  • 1
    Yeah, but I can imagine a sort of "Linq to the Cloud" project where you pass a "where" clause to a service, and it returns, say, the first 100 rows matching that clause. – Matt Hamilton Feb 19 '09 at 21:55
  • 1
    For that scenario, perhaps the type of wrapping that Astoria does is the way to go... – Marc Gravell Feb 20 '09 at 00:36
  • Sure. I guess it depends on what you're trying to do. As I understand Astoria, it's very "single-table" focused - it'd be hard to pass an expression that looked at Order.Customer.Address.State == "CA", for example. – Matt Hamilton Feb 20 '09 at 00:54
  • I am trying to do exactly the "where" scenario that you mentioned. – KevDog Feb 20 '09 at 01:25