Web Api - Does it support filters etc

Created a .net Web Api with a class and a controller. Using standard rest verbs i'm able to perform actions against all the http verbs. Out of the box does it support filters, top, sort, etc. Does not seem to work for me.
glenn_rAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Najam UddinCommented:
No, for that you have to implement logic
glenn_rAuthor Commented:
Any templates that implement all that standard REST stuff?
Najam UddinCommented:
Well, you have to support basic verbs. GET, POST, PATCH, DELETE, rest of things top, sort will go as GET. Other thing you should consider about is diff in PUT and POST and correctly implement PATCH

PUT is idempotent, so if you PUT an object twice, it has no effect.
glenn_rAuthor Commented:
any examples on how to implement this?
Najam UddinCommented:
Check this tutorial

public class BooksController : ApiController
{
    // GET api/values
    public IEnumerable<book> Get()
    {
        using (SampleDbEntities entities = new SampleDbEntities())
        {
            return entities.Books.ToList<book>();
        }
    }
 
    // GET api/values/5
    public Book Get(int id)
    {
        using (SampleDbEntities entities = new SampleDbEntities())
        {
            return entities.Books.SingleOrDefault<book>(b => b.ID == id);
        }
    }
 
    // POST api/values
    public HttpResponseMessage Post(Book value)
    {
        try
        {
            if (ModelState.IsValid)
            {
                using (SampleDbEntities entities = new SampleDbEntities())
                {
                    entities.Books.AddObject(value);
                    entities.SaveChanges();
                    return Request.CreateResponse(HttpStatusCode.OK);
                }
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, "Invalid Model");
            }
        }
        catch (Exception ex)
        {
            return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
        }
    }
 
    // PUT api/values/5
    public HttpResponseMessage Put(int id, Book value)
    {
        try
        {
            using (SampleDbEntities entities = new SampleDbEntities())
            {
                Book foundBook = entities.Books.SingleOrDefault<book>(b => b.ID == id);
                foundBook.BookName = value.BookName;
                entities.SaveChanges();
                return Request.CreateResponse(HttpStatusCode.OK);
            }
        }
        catch (Exception ex)
        {
            return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
        }
    }
 
    // DELETE api/values/5
    public HttpResponseMessage Delete(int id)
    {
        try
        {
            using (SampleDbEntities entities = new SampleDbEntities())
            {
                Book foundBook = entities.Books.SingleOrDefault<book>(b => b.ID == id);
                entities.Books.DeleteObject(foundBook);
                entities.SaveChanges();
                return Request.CreateResponse(HttpStatusCode.OK);
            }
        }
        catch (Exception ex)
        {
            return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
        }
    }
} 

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.