1

这是我的代码:

//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);
        }
}

我的问题是我试图在实体框架中写下或形成类似的查询,但似乎它不支持它。

4

2 回答 2

3

您可以使用.Contains,它是LIKE实体框架中等效的运算符。

于 2012-10-27T19:55:13.753 回答
1

你可以用这个

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

:)

于 2012-10-29T05:51:05.653 回答