Ramco Ramco

Ramco Ramco

  • 437
  • 3.4k
  • 541.8k

Get Data using Linq Query

Dec 2 2022 2:03 PM

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<MachineMaster> objResult = (from t in context.MachineMasters
                                                  where (Product != "" ? Product.Contains(t.ID.ToString()) : 1 == 1)
                                                  select t).ToList();

Thanks


Answers (2)