Can you possibly build the lambda expression in code?
e.g. the example from http://msdn.microsoft.com/en-us/library/bb397951.aspx
// the lambda expression num => num < 5.
ParameterExpression numParam = Expression.Parameter(typeof(int), "num");
ConstantExpression five = Expression.Constant(5, typeof(int));
BinaryExpression numLessThanFive = Expression.LessThan(numParam, five);
Expression<Func<int, bool>> lambda1 =
Expression.Lambda<Func<int, bool>>(
numLessThanFive,
new ParameterExpression[] { numParam });
Regards,
Colin Savage
From: [email protected]
[mailto:[email protected]] On Behalf Of David Burela
Sent: Monday, 6 September 2010 4:15 PM
To: ozSilverlight
Subject: Ria Services : Where clause with multiple items
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
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight