You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Only started using OneOf last week on a refurbishing project for one of our old .Net FW projects moving it to .Net 8. It worked great for removing the "running on bugs" anti pattern. No more magical error handler in the pipeline outside of the specific IActionResult action logic.
However, now I need to tackle the next problem, a very inefficient bulk operation and I would like the following signature on my new bulk db method
public OneOf<IEnumerable, Error>
with yield return for each actual data point and return of error if something goes wrong. Heck even
public OneOf<IEnumerable, IEnumerable>
would make sense if you're willing to capture all the errors but proceed with the processing of the input. Maybe it even makes more sense in a way.
However, the compiler says no :-(
The body of 'BulkInsert' cannot be an iterator block because 'OneOf<System. Collections. Generic. IEnumerable,Error>' is not an iterator interface type (actual types obfuscated).
Any chance of something like this or is this just outside the paradigm? The more I look at it the more it feels like it, but there might be smarter people than me out there ;-)
Regards
M
The text was updated successfully, but these errors were encountered:
This is a skeleton that approaches the issue using exceptions. Make sure you use .NET 9, which has introduced significant performance improvements in this regard.
Hi,
Only started using OneOf last week on a refurbishing project for one of our old .Net FW projects moving it to .Net 8. It worked great for removing the "running on bugs" anti pattern. No more magical error handler in the pipeline outside of the specific IActionResult action logic.
However, now I need to tackle the next problem, a very inefficient bulk operation and I would like the following signature on my new bulk db method
public OneOf<IEnumerable, Error>
with yield return for each actual data point and return of error if something goes wrong. Heck even
public OneOf<IEnumerable, IEnumerable>
would make sense if you're willing to capture all the errors but proceed with the processing of the input. Maybe it even makes more sense in a way.
However, the compiler says no :-(
The body of 'BulkInsert' cannot be an iterator block because 'OneOf<System. Collections. Generic. IEnumerable,Error>' is not an iterator interface type (actual types obfuscated).
Any chance of something like this or is this just outside the paradigm? The more I look at it the more it feels like it, but there might be smarter people than me out there ;-)
Regards
M
The text was updated successfully, but these errors were encountered: