首页 > 解决方案 > 编译表达式的性能

问题描述

我有以下方法并对编译表达式的性能影响感到好奇。

    public async Task<Response<TResult>> Execute<TApi, TResult>(Expression<Func<TApi, Task<TResult>>> executeApiMethod)
    { 
        try
        {
            var responseData = await executeApiMethod.Compile()(restApi).ConfigureAwait(false);
            return new Response<TResult>(responseData);
        }
        catch (ApiException refitApiException)
        {


            throw;
        }
    }

有没有更好的办法?是否有任何性能影响compile(),因为这是通用的,并且每次运行 compile 时都可能使用不同的参数调用是 scavy。

标签: c#genericsfunc

解决方案


推荐阅读