views:

1983

answers:

3

Hi

I want to pass a custom class as parameter to the query method which returns me a collection of entities. I need something like this

[Query] public IEnumerable Search(SearchParams params) { //do something here }

public class SearchParams { public string FilterParam1 {get; set;} public string FilterParam2 {get; set;} public string FilterParam3 {get; set;} public string FilterParam4 {get; set;} public string FilterParam5 {get; set;} ...and so on... } I tried making SearchParams class available at client side using shared code. But the problem is that no operation(query or invoke) let me create a method where I can pass SearchParams class as it is not a native serializable type. I have about 15 properties in SearchParams class like this.

I do not want to create a Query operation with 15 parameters. Please suggest is there's a good workaround for that.

A: 

I think you missed the whole point with the Query method ;) The Load method which you use to "excute" the query method takes a Query as an argument. Use that one instead of using your own "query object". For example something like this:

EntityQuery query = from e in dx.GetYourEntityQuery() where e.Foo == "something" select e;

dx.Load(query);

/Fredrik Normén

Fredrik Normén
Yeaps you r right. I just missed the whole point
Gaurave Sehgal
But the problem with using this solution is that I m using a custom entity framework and there it uses stored procedure. It brings all the records to the web server and then filters them. Performance hit :(. So still it's an open question
Gaurave Sehgal
A: 

As Frederick said, one of the main points of RIASvcs is you can send a custom query (LINQ expression) over the wire from the client, to the server, and have it executed there.

It brings all the records to the web server and then filters them.

If I understand you correctly, this isn't true-- bring up Fiddler and see what gets sent back-and-forth, it is indeed filtering on the server and only returning (to the client) what was asked for.

Bobby
Yes, I agree to you too. But I don't even want to bring all the records to server and then filter them. I want to filter them at database level only. I can do that by sending few parameters, but in my case I have 15 parameters. I don't want to create a method with 15 parameter. I want to create a custom object to send as parameter.
Gaurave Sehgal
A: 

If you read what Martin Fowler says about SOA: When you're working with a remote interface, such as Remote Facade (388), each call to it is expensive. As a result you need to reduce the number of calls, and that means that you need to transfer more data with each call So your question has only one answer, yes. It doesn't make sense to expose complex type like Expression or Func through WCF just because you want to provide a simple syntax in the client. You have the DataContract, use that to expose a Dto that represent your query.