I have this method, firstly, it gets all data from database (joined tables), then it filters the result with search property and search keyword, as follow. Everything is fine until I add switch ... case with LINQ, and I get the error "Metadata .dll could not be found". Obviously, the error comes from it, but I have no clue what error is, I am so new to LINQ.
public IPagedList<dynamic> Execute(int pageIndex, int pageSize, string searchProperty, string searchKeyword)
{
IQueryable<dynamic> dokumente;
dokumente = session.Query<Dokument>().Select(dokument =>
new {Beschreibung = dokument.Beschreibung,
Link = dokument.Link,
Dokumenttyp = dokument.Dokumenttyp.Bezeichnung,
}).ToList().AsQueryable();
if (!string.IsNullOrEmpty(searchProperty))
{
switch (searchProperty)
{
case "Beschreibung":
dokumente = dokumente.Where(x => x.Beschreibung == searchKeyword);
break;
case "Link":
dokumente = dokumente.Where(x => x.Link == searchKeyword);
break;
case "Dokumenttyp":
dokumente = dokumente.Where(x => x.Dokumenttyp == searchKeyword);
break;
}
}
return new PagedList<dynamic>(dokumente, pageIndex, pageSize);
}