kari kalan kari kalan -4 years ago 56
SQL Question

single where Contains Check For All Column in Linq Query

i have a table 30 column ,
1000 records in a table
i want single linq query single where case

for example format:

table.where(allcolumnvalue.contains(searchvalue)).Tolist()


one where clause search for contains word all column .
how is it possible ?
any answer welcome

Answer Source

using code

public class GenericList<T>
{
     public List<T> SerachFun(List<T> input, string search)
     {
            List<T> output = new System.Collections.Generic.List<T>();
            foreach (var aa in input)
            {
               var columns = aa.GetType().GetProperties().ToList();
               foreach (var bb in columns)
               {
                  var cccc = bb.GetValue(aa);
                  if(cccc!=null)
                  {
                     bool result = cccc.ToString().Contains(search);
                     if (result)
                     {
                        output.Add(aa);
                        continue;
                      }
                  }

              }

         }
            return output;
    }
  }

Try call method

 public GenericList<table1> g = new GenericList<table1>();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download