AspNetCore.Docs/aspnet/whitepapers/whats-new-in-aspnet-45-and-.../samples/sample26.cs

11 lines
241 B
C#

public IQueryable<Product>
GetProducts([QueryString]string keyword)
{
IQueryable<Product> query = _db.Products;
if (!String.IsNullOrWhiteSpace(keyword))
{
query = query.Where(p => p.ProductName.Contains(keyword));
}
return query;
}