【问题标题】:Calling an overloaded C# method that takes an Action<A> or a Action<A,B> from F#调用从 F# 获取 Action<A> 或 Action<A,B> 的重载 C# 方法
【发布时间】:2020-02-18 22:25:03
【问题描述】:

这是两个重载的签名。

public static IServiceCollection AddDbContextPool<TContext>(
    this IServiceCollection serviceCollection,
    Action<DbContextOptionsBuilder> optionsAction,
    int poolSize = 128) where TContext : DbContext { ...

public static IServiceCollection AddDbContextPool<TContext>(
    this IServiceCollection serviceCollection,
    Action<IServiceProvider, DbContextOptionsBuilder> optionsAction,
    int poolSize = 128)
    where TContext : DbContext { ...

这是在 C# 中调用的第二个重载

但是当我尝试从 F# 调用第二个重载时,我得到了这个错误:

我该如何解决这个问题?谢谢!

【问题讨论】:

  • 尝试传递fun (sp: IServiceProvider) (optionsBuilder: ...) -&gt; ...
  • @AMieres Ulgh,就是这样。复制粘贴到答案,我会接受 =)

标签: f# overloading c#-to-f#


【解决方案1】:

尝试通过:

fun (sp: IServiceProvider) (optionsBuilder: ...) -> ...

【讨论】:

    猜你喜欢
    • 2016-09-16
    • 2013-06-12
    • 1970-01-01
    • 1970-01-01
    • 2020-12-25
    • 1970-01-01
    • 1970-01-01
    • 2020-07-15
    • 1970-01-01
    相关资源
    最近更新 更多