Skip to main content
deleted 6 characters in body
Source Link
Nannanas
  • 631
  • 3
  • 9

This warning occurs because GetDisplayName() is a custom method implemented in your code and cannot be accessed by the database or translated to any sort of sql statement. Therefore EF needs to load all entities from the database and performs filtering in memory (which you should avoid because filtering on the database is much faster).

What you need to to is "Reverse engineer" the term the user searched for to the actual enum value e.g. like so

var filteredStatus = Enum.GetValues(typeofGetValues<Status>(Status))
                         .Where(value => value.GetDisplayName().Contains(searchBy))
                         .ToList();

and then in your query instead of using r.Status.GetDisplayName().Contains(searchBy) use filteredStatus.Contains(r.Status)

This warning occurs because GetDisplayName() is a custom method implemented in your code and cannot be accessed by the database or translated to any sort of sql statement. Therefore EF needs to load all entities from the database and performs filtering in memory (which you should avoid because filtering on the database is much faster).

What you need to to is "Reverse engineer" the term the user searched for to the actual enum value e.g. like so

var filteredStatus = Enum.GetValues(typeof(Status))
                         .Where(value => value.GetDisplayName().Contains(searchBy))
                         .ToList();

and then in your query instead of using r.Status.GetDisplayName().Contains(searchBy) use filteredStatus.Contains(r.Status)

This warning occurs because GetDisplayName() is a custom method implemented in your code and cannot be accessed by the database or translated to any sort of sql statement. Therefore EF needs to load all entities from the database and performs filtering in memory (which you should avoid because filtering on the database is much faster).

What you need to to is "Reverse engineer" the term the user searched for to the actual enum value e.g. like so

var filteredStatus = Enum.GetValues<Status>()
                         .Where(value => value.GetDisplayName().Contains(searchBy))
                         .ToList();

and then in your query instead of using r.Status.GetDisplayName().Contains(searchBy) use filteredStatus.Contains(r.Status)

Source Link
Nannanas
  • 631
  • 3
  • 9

This warning occurs because GetDisplayName() is a custom method implemented in your code and cannot be accessed by the database or translated to any sort of sql statement. Therefore EF needs to load all entities from the database and performs filtering in memory (which you should avoid because filtering on the database is much faster).

What you need to to is "Reverse engineer" the term the user searched for to the actual enum value e.g. like so

var filteredStatus = Enum.GetValues(typeof(Status))
                         .Where(value => value.GetDisplayName().Contains(searchBy))
                         .ToList();

and then in your query instead of using r.Status.GetDisplayName().Contains(searchBy) use filteredStatus.Contains(r.Status)