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,261
  • 2
  • 14
  • 27

2 Answers2

3

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

Community
  • 1
  • 1
Kamyar
  • 18,406
  • 9
  • 94
  • 169
1

you can use this

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

:)

Kaps Hasija
  • 2,037
  • 5
  • 19
  • 31