1

Here is my code:

//order my baselist is context.Entity 
public static GridData Getdata<T>(ObjectSet<T> baseList,
    int currentPage,
    int rowsPerPage,
    string sortcolumn,
    string sortord,
    string searchQuery,
    string searchColumns)where T: class{
var query = baseList.OrderBy("it." + sortcolumn + " " + sortord);
        string strPredicate = string.Empty;
        if (!string.IsNullOrEmpty(searchColumns))
        {
            strPredicate = "it." + searchColumns + " LIKE   @" + searchColumns + "  ";

            query = baseList.Where(strPredicate, new ObjectParameter(searchColumns, searchQuery)).OrderBy("it." + sortcolumn + " " + sortord);
        }
}

My problem is i am trying to write down or form a like query in entity framework and seems like it does not support it.

Rusty
  • 1,303
  • 2
  • 14
  • 28

2 Answers2

3

You can use .Contains which is the LIKE operator equivalent in entity framework.

Community
  • 1
  • 1
Kamyar
  • 18,639
  • 9
  • 97
  • 171
1

you can use this

 query = baseList.Where(baseli=>baseli.Contains(searchColumns )).OrderBy("it." + sortcolumn + " " + sortord);

:)

Kaps Hasija
  • 2,097
  • 5
  • 23
  • 31