Check this:
Attribution = _UnitOfWork.Attribution.Find( a => a.Description.Contains( SearchString ) ).ToList();
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I have a C# ASP N-Tier .Net 6 Razor (non-MVC) web application that is using a standard Repository Pattern and Unit of Work.
Partial view below:
public IEnumerable<T> GetAll()
{
IQueryable<T> query = dbSet;
return query.ToList();
}
public IEnumerable<T> Find(Expression<Func<T, bool>> expression)
{
return _db.Set<T>().Where(expression);
}
In my index.cshtml page I have a small form that allow a user to Search/Filter the data displayed on the page:
The input from that search box is captured in the following Property:
[BindProperty(SupportsGet = true)]
public string SearchString { get; set; }
If SearchString has a value I want to return a subset of the data, based on the user's input.
If it does not have a value I GetAll().
public void OnGet()
{
if (!string.IsNullOrEmpty(SearchString))
{
var attributionList = from attribution in Attribution
where attribution.Description
.Contains(SearchString)
select attribution;
Attribution = _UnitOfWork.Attribution.GetAll().Select(attributionList);
}
else
{
Attribution = _UnitOfWork.Attribution.GetAll();
}
}
I am receiving the following error on this part of the code:
.Select(attributionList)
Error CS0411
The type arguments for method 'Enumerable.Select<TSource, TResult>(IEnumerable<TSource>, Func<TSource, int, TResult>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Any help in resolving this is greatly appreciated.
Thanks for your time!
Check this:
Attribution = _UnitOfWork.Attribution.Find( a => a.Description.Contains( SearchString ) ).ToList();