From the documentation
You can customize how Web API handles exceptions by writing an exception filter. An exception filter is executed when a controller method throws any unhandled exception[...]
The problem is that if you return an
IEnumerable<T> from your WebAPI method, the error will occur during serialization, when the
IEnumerable<T> is iterated. This is the standard behavior of
Select (and most other query operators) it only call the method passed to it upon iteration (
MakeFooFromBar in this case), so the exception will not be thrown when you invoke
Select but much later.
You could add a
.ToList to cause the exception to occur inside your method.
- Web API filters not catching exceptions thrown from a method group
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- I want to bring data from multiple tables with entityframework using linq method in dotnetcore web api controller
- Exception thrown Getting items from group using fluent api
- How to create an IQueryable Web API that can pull data from several data sources?
- creating Linq to sqlite dbml from DbLinq source code
- LINQ to Entities does not recognize the method group join
- LINQ query JOIN two tables for Web API controller method
- LINQ method syntax to group by a column, pick one element from each group with total count per group
- Returning data from multiple sql tables entity framework web api
- Parsing tags which are not closed from web page with HtmlAgilityPack
- Can someone tell me why this simple bit of c# code won't work, involves recursively calling method from within itself to get the root category ID
- post method in API not working as expected
- LINQ Group by - linq to entities does not recognize the method 'char get_chars(int32) method
- Select only few columns from a table to map with Odata Select query on C# Web API
- Web Api 2 - converting values and combine values from sub query
- C# exclude duplicate code from two method returning expression
- Calling a shared code from Page method and WebApi Controller with Razor Pages
- Partial update in Web API is not working
- Send IEnumerable from web api controller to angular js
- C# return linq result as a list from a wcf service method then use it in aspx web forms page
- ASP.NET web forms displaying data from a table but stuck with the method behind
- using Automapper with LINQ in Web Api get method
- Group method not recognized in LINQ query
- Returning a single property of a Model in HttpGet Method in ASP.NET Core Web API
- Entity Framework method group Include does not work
- LINQ Recursive query in web api code
- Why does my method not run when I attempt to delete a Record from my database using a strongly-typed Delete View?
- Using LINQ's Except<> method with an object from an external API
- Can Not Convert From Expression<Func<T, decimal>> To Func<T, decimal> In Sum Method in Lambda Expression
More Query from same tag
- Linq to objects very slow compared to dataview
- Crafting a LINQ based solution to determine if a set of predicates are satisfied for a pair of collections constrained by a set of invariants
- Linq to entities(latest entity framework) get many to many and one to many relation
- How to get the count of the values that are repeated in c#
- Dynamic linq query with dynamic where conditions and from conditions
- How to create json structure from list of data?
- How to add several dependent records with LINQ2SQL
- Check if record exists with specific attribute.
- How to Load type from string directly into linq expression in C#?
- LINQ where Clause doubt
- Need some help on a somewhat complex LINQ query
- Implement linq's Cast<T>() on single objects
- Linq OrderBy calculated property
- How to calculate population standard deviation foreach double in a list of Double?
- Selecting only part of the DbSet in Read method of Kendo grid
- select distinct results using linq
- Rewriting code using LINQ
- How to get a list of objects from Entity Framework database?
- Join two arrays and get tuple
- WCF, Linq Error:cannot implicitly convert type System.linq.iorderedQueryable<> to System.Collection.Generic.List<>
- VB.NET LINQ join
- Implementing IQueryable and ASTs for finding entities in a game
- where linq with trim replace character and ignore case
- Get a IEnumerable<T> from a IEnumerable<IEnumerable<T>>
- How linq-to-nhibernate between 2 lists by StartsWith
- Append a number to duplicate values in data table c#
- Sorting a list of objects by another list of objects VB.NET LINQ
- Is there a way to search in Dictionary<int, List<int> by values inside values faster than this code already does?
- Get specific table depending on week ASP.NET MVC LINQ
- How to convert an expression to linq with nested foreach when the first element is being modified