编译表达式的性能

时间:2019-03-11 06:31:44

标签: c# generics func

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

    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()是否会对性能产生影响,因为这是通用的,每次运行编译时都会用不同的参数调用。

0 个答案:

没有答案