Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async methods are throwing exceptions because Task.FromResult does not specify type <T> #317

Open
efron-cem opened this issue Apr 19, 2023 · 0 comments

Comments

@efron-cem
Copy link

The async CRUD methods like GetAsync are sometimes throwing exceptions like below

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The type arguments for method 'System.Threading.Tasks.Task.FromResult<TResult>(TResult)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
   at CallSite.Target(Closure , CallSite , Type , Object )
   at DapperExtensions.DapperAsyncImplementor.GetAsync[T](IDbConnection connection, Object id, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered, IList`1 colsToSelect, IList`1 includedProperties)
   at CallSite.Target(Closure , CallSite , Object )
   at DapperExtensions.DapperAsyncExtensions.GetAsync[T](IDbConnection connection, Object id, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered)
   at Repository.GetAsync(SqlConnection connection, Guid blueprintId) in myfile.cs:line -1

I assume this happens when there is nothing in the database, and the async method's Task.FromResult have trouble with returning it because it doesn't know what type null is. The type just needs to be added to the Task.FromResult call, it should be a very quick and easy fix.

The methods are in DapperAsyncImplementor.cs

Please and Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant