I try to filtering the data that return to kendo combo box, the filtering is based on the ID, I need to return all records that contains the filtration text not only the equals one, so what I did is to cast the ID to string as the following snip
Items = Mapper.Map<List<PurchaseOrder>, List<PurchaseOrderViewModel>>(
purchaseOrderRepository.GetMany(x =>
x.PurchaseOrderID
.ToString()
.Contains(text))
.ToList());
but it's always return linq to entities does not recognize the method 'system.string tostring()'
so I tried to convert the dbset to list before the where statement as I found in another post LINQ to Entities does not recognize the method 'System.String ToString()' method in MVC 4 but I got another error says that the list does not contains a definition for Where (dbSet is an instance of IDbSet)
public virtual IList<T> GetMany(Expression<Func<T, bool>> where)
{
return dbset.ToList().Where(where).ToList();
}
here is My original(current) get method
sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Data;
using System.Linq.Expressions;
using Spine.ERP.DataAccess.DbFirstDataAccess;
using Spine.ERP.DataModel.Helpers;
namespace Spine.ERP.DataAccess.Infrastructure
{
public abstract class RepositoryBase<T> where T : class
{
private SSSDBEntities dataContext;
private readonly IDbSet<T> dbset;
protected RepositoryBase(IDatabaseFactory databaseFactory)
{
DatabaseFactory = databaseFactory;
dbset = DataContext.Set<T>();
}
protected IDatabaseFactory DatabaseFactory
{
get;
private set;
}
protected SSSDBEntities DataContext
{
get { return dataContext ?? (dataContext = DatabaseFactory.Get()); }
}
public virtual IQueryable<T> GetMany(Expression<Func<T, bool>> where)
{
return dbset.Where(where);
}
}
}
Any other thing can I do to solve this problem?