Re: Ria Services : Where clause with multiple items
Hi David Check out the PredicateBuilder from J. Albahiri (Nesting Predicates) Source here http://www.albahari.com/nutshell/predicatebuilder.aspx http://www.albahari.com/nutshell/predicatebuilder.aspx.peter.gfader. http://blog.gfader.com/ http://twitter.com/peitor On Mon, Sep 6, 2010 at 4:15 PM, David Burela david.bur...@gmail.com wrote: This seems like a simple problem but I am stumped. I have a screen with a number of filters. In one instance I have checkboxes of countries (Australia, China, Japan, etc). I want to filter to only show products that are located in the checked countries. So products listed in Australia OR in China OR in Japan. My issue is that the RIA servies query object, only lets you chain up ANDs var query = ProductDomainContext.ProductSelectQuery(); if(AustraliaIsSelected) query = query.Where(p = p.Country == Australia); if(ChinaIsSelected) query = query.Where(p = p.Country == China); Doing it this way will end up with a query where the country is Australia AND China. I was hoping I could go var checkedCountries = new []{Australia, China}; query = query.Where(p = checkedCountries.Contains(p.Country) But RIA complains that it does not support the contains operation. Any ideas? -David Burela P.S. I can't do it on one line like this query.Where(p = p.Country==Australia || p.Country == China); Because at runtime I don't know how many are there. The above is just a simplified example ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight -- .peter.gfader. http://blog.gfader.com/ http://twitter.com/peitor ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
Re: Ria Services : Where clause with multiple items
This sounded like the perfect solution. But unfortunately RIA crashes *Nested query expressions are not supported* -David Burela On 6 September 2010 16:41, Peter Gfader pe...@gfader.com wrote: Hi David Check out the PredicateBuilder from J. Albahiri (Nesting Predicates) Source here http://www.albahari.com/nutshell/predicatebuilder.aspx http://www.albahari.com/nutshell/predicatebuilder.aspx.peter.gfader. http://blog.gfader.com/ http://twitter.com/peitor On Mon, Sep 6, 2010 at 4:15 PM, David Burela david.bur...@gmail.comwrote: This seems like a simple problem but I am stumped. I have a screen with a number of filters. In one instance I have checkboxes of countries (Australia, China, Japan, etc). I want to filter to only show products that are located in the checked countries. So products listed in Australia OR in China OR in Japan. My issue is that the RIA servies query object, only lets you chain up ANDs var query = ProductDomainContext.ProductSelectQuery(); if(AustraliaIsSelected) query = query.Where(p = p.Country == Australia); if(ChinaIsSelected) query = query.Where(p = p.Country == China); Doing it this way will end up with a query where the country is Australia AND China. I was hoping I could go var checkedCountries = new []{Australia, China}; query = query.Where(p = checkedCountries.Contains(p.Country) But RIA complains that it does not support the contains operation. Any ideas? -David Burela P.S. I can't do it on one line like this query.Where(p = p.Country==Australia || p.Country == China); Because at runtime I don't know how many are there. The above is just a simplified example ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight -- .peter.gfader. http://blog.gfader.com/ http://twitter.com/peitor ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
RE: Ria Services : Where clause with multiple items
Lambda expressions are serialisable with the right serialiser. you could have a custom service method that takes a string as input which happens to be the serialised lambda. Deserialise it and apply the lambda to your entity model and then return the results. Have no idea if this would actually work though J From: ozsilverlight-boun...@ozsilverlight.com [mailto:ozsilverlight-boun...@ozsilverlight.com] On Behalf Of David Burela Sent: Monday, 6 September 2010 5:10 PM To: ozSilverlight Subject: Re: Ria Services : Where clause with multiple items This sounded like the perfect solution. But unfortunately RIA crashes Nested query expressions are not supported -David Burela On 6 September 2010 16:41, Peter Gfader pe...@gfader.com wrote: Hi David Check out the PredicateBuilder from J. Albahiri (Nesting Predicates) Source here http://www.albahari.com/nutshell/predicatebuilder.aspx .peter.gfader. http://blog.gfader.com/ http://twitter.com/peitor On Mon, Sep 6, 2010 at 4:15 PM, David Burela david.bur...@gmail.com wrote: This seems like a simple problem but I am stumped. I have a screen with a number of filters. In one instance I have checkboxes of countries (Australia, China, Japan, etc). I want to filter to only show products that are located in the checked countries. So products listed in Australia OR in China OR in Japan. My issue is that the RIA servies query object, only lets you chain up ANDs var query = ProductDomainContext.ProductSelectQuery(); if(AustraliaIsSelected) query = query.Where(p = p.Country == Australia); if(ChinaIsSelected) query = query.Where(p = p.Country == China); Doing it this way will end up with a query where the country is Australia AND China. I was hoping I could go var checkedCountries = new []{Australia, China}; query = query.Where(p = checkedCountries.Contains(p.Country) But RIA complains that it does not support the contains operation. Any ideas? -David Burela P.S. I can't do it on one line like this query.Where(p = p.Country==Australia || p.Country == China); Because at runtime I don't know how many are there. The above is just a simplified example ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight -- .peter.gfader. http://blog.gfader.com/ http://twitter.com/peitor ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
RE: Ria Services : Where clause with multiple items
That would work but breaks the abstraction. Presumably this is part of his IRepositoryT. We have the same abstraction and instead of putting lambdas straight onto the repository.Entities, we instead use the SpecificationT pattern. Even still we would still have the same problem. From: ozsilverlight-boun...@ozsilverlight.com [mailto:ozsilverlight-boun...@ozsilverlight.com] On Behalf Of Jordan Knight Sent: Monday, 6 September 2010 7:13 PM To: ozSilverlight Subject: Re: Ria Services : Where clause with multiple items Pass the params up to the server and process it there... (just add a param to your query method) Cheers, Jordan. On 06/09/2010, at 4:15 PM, David Burela david.bur...@gmail.com wrote: This seems like a simple problem but I am stumped. I have a screen with a number of filters. In one instance I have checkboxes of countries (Australia, China, Japan, etc). I want to filter to only show products that are located in the checked countries. So products listed in Australia OR in China OR in Japan. My issue is that the RIA servies query object, only lets you chain up ANDs var query = ProductDomainContext.ProductSelectQuery(); if(AustraliaIsSelected) query = query.Where(p = p.Country == Australia); if(ChinaIsSelected) query = query.Where(p = p.Country == China); Doing it this way will end up with a query where the country is Australia AND China. I was hoping I could go var checkedCountries = new []{Australia, China}; query = query.Where(p = checkedCountries.Contains(p.Country) But RIA complains that it does not support the contains operation. Any ideas? -David Burela P.S. I can't do it on one line like this query.Where(p = p.Country==Australia || p.Country == China); Because at runtime I don't know how many are there. The above is just a simplified example ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight ___ ozsilverlight mailing list ozsilverlight@ozsilverlight.com http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight