New pattern coming to MVC Core 2.1, ActionResult returns
From David Fowler's own mouth:
It's a discriminated union that solves the, I want to return an object or a 404 without needing to throw an exception.
TL;DR on example:
[HttpGet] public ActionResult<Product> GetProduct(int? productId) { if (productId == null) { return BadRequest(); } return new Product { SampleInt = productId.Value, }; }
0 comments:
Post a Comment