InvalidOperationException: enter "System.String" referencing the scope '' but not defined

I upgraded to Core 1.1 and Visual Studio 2017. I am running a simple existing line of code to find a column for a user-entered row, but I get an error ...

InvalidOperationException: variable '__searchTerm_1' of type 'System.String' is referenced from scope '' but not defined

In short, my code is:

public IQueryable<SearchViewModel> ActivitySearch(string searchTerm) { var qry = (from act in context.Acts .Include(x => x.ActivityExt) select new SearchViewModel() { AMCNnumber = act.AMCNnumber ActivityId = act.ActivityID, ImplementingPartner = act.ActivityExt.imp, ProjectTitle = act.Name, Description = act.Description, StartDate = act.StartDate, EndDate = act.EndDate }); if (!String.IsNullOrEmpty(searchTerm)) { qry = qry.Where(x => x.AMCNnumber.Contains(searchTerm); } return qry.ToArray(); } 
+5
source share
1 answer

It turns out that the request I had was causing an error. I needed to create a separate variable to get the identifier.

0
source

Source: https://habr.com/ru/post/1260093/


All Articles