The below function returns all the rows in Files table even when the where filter if applied,
public IList<File> SearchFiles(int? FileID, int? type, int? Status)
{
var files = from fil in _context.Files
select fil;
if (FileID != null)
{
files.Where(x => x.FileID == FileID);
}
if (type != null)
{
files.Where(x => x.FileTypeID == type);
}
if (Status != null)
{
files.Where(x => x.FileStatusID == Status);
}
return files.ToList<File>();
}
Any mistake i am doing here?
Thanks in advance!
You need to assign the Where back to the IQueryable…. (ie: files = files.where(….