that_guy_jrb
that_guy_jrb

Reputation: 59

How to Filter results in ASP.net core based on a data

I am able to get a List of data inside a variable. Now, what I want is to filter it on the basis of a value IsDeleted. If the value of IsDeleted is true I don't have to show that result and exclude it from the List, else I have to show the data.

Here's my code for the Same:

[HttpGet]
    public ActionResult<IEnumerable<Vendor>> Get()
    {
        var VendorList = context.Vendor.ToList();
        return Ok(VendorList); 
    }

Upvotes: 0

Views: 271

Answers (1)

cdev
cdev

Reputation: 5351

use where clause to do filter.

[HttpGet]
public ActionResult<IEnumerable<Vendor>> Get()
{
    var VendorList = context.Vendor.where(x => x.IsDeleted == false).ToList();
    return Ok(VendorList); 
}

Upvotes: 2

Related Questions