Skip to content

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

@efron-cem

Description

@efron-cem

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions