データベースで特定のクエリを実行し、クライアントブラウザに返すデータのプレゼンテーションモデルを作成するために使用している次のクラスがあります。
public class SpecificFooQuery: IPresentationQuery<FooRequest, FooResult>
{
public SpecificFooQuery(ILogger logger, DbContext context)
{
this.logger = logger;
this.context = context;
}
public FooResult Get(FooRequest request)
{
return new FooResult { ... };
}
}
次の汎用インターフェースを実装します
public interface IPresentationQuery<TRequest, TResult>
where TRequest : class
where TResult : class
{
TResult Get(TRequest request);
}
しかし、オブジェクトを作成するためのインスタンス化を作成するのに問題があります。これは機能しませんが、これ以上のことは今のところありません。
kernel.Bind<IPresentationQuery<FooResult, FooRequest>>().To<SpecificFooQuery>();
誰かがこれを手伝ってくれる?私はどこが間違っているのか、この仕事をするために何をする必要があるのかよくわからない。
Error 1
The type 'SpecificFooQuery' cannot be used as type parameter
'TImplementation' in the generic type or method
'Ninject.Syntax.IBindingToSyntax<T1>.To<TImplementation>()'.
There is no implicit reference conversion from
'SpecificFooQuery' to 'IPresentationQuery<FooResult,FooRequest>'.