Hi
I have got a collection in variable . I want to display all records of those collections. In Database ID is of int DataType.
In Product it is showing "2001,2002"
I am getting error- Only arguments that can be evaluated on the client are supported for the String.Contains method.
if (lstProduct.Items[i].Selected)
{
Product += lstProduct.Items[i].Value.ToString() + ",";
}Product = Product.Trim().TrimEnd(',');
System.Collections.Generic.List
where (Product != "" ? Product.Contains(t.ID.ToString()) : 1 == 1)
select t).ToList();
Thanks

Aravind GovindarajRank #430 · 5.8K reputationPosted Dec 4, 2022, 1:10 PM EST
the first option please apply the indexOf instead of Contains,
second option use lstproduct.any(t.ID.Tostring)
Jignesh KumarRank #91 · 22.9K reputationPosted Dec 4, 2022, 10:32 PM EST
Hello Ramco,
You can convert comma seperated string in to string array then you can check contains on that,
Product = Product.Trim().TrimEnd(','); Var products = Product..Split(',') System.Collections.Generic.List objResult = (from t in context.MachineMasters where (products != "" && products.Any() ? products .Contains(t.ID.ToString()) : 1 == 1) select t).ToList();