Reputation: 197
Im following a guide of how to setup SQLite. In the guide he uses code-behind like this:
public MainPage()
{
InitializeComponent();
// Setup database
var path = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "test.sqlite"));
_connection = new SQLiteConnection(new SQLitePlatformWP8(), path);
}
Im trying to do the same thing but instead by following MVVM. I thought his would be the way to go:
public override void Load()
{
var path = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "test.sqlite"));
Bind<ISQLitePlatform>().To<SQLitePlatformWP8>().WithConstructorArgument("test.sqlite", path);
}
Ninject responds with:
No matching bindings are available, and the type is not self-bindable.
Activation path:
4) Injection of dependency string into parameter databasePath of constructor
3) Injection of dependency SQLiteConnection into parameter connection of constructor
2) Injection of dependency ICarRepository into parameter carRepository of constructor
1) Request for MainVModel
Any tips on how to solve this one?
Upvotes: 3
Views: 2290
Reputation: 139758
The SQLiteConnection
needs the parameter and not the SQLitePlatformWP8
.
So change your registration to:
Bind<SQLiteConnection>.ToSelf().WithConstructorArgument("databasePath", path);
Bind<ISQLitePlatform>().To<SQLitePlatformWP8>();
Note: you need to use the correct paramter name "databasePath"
which is definied in the SQLiteConnection
class's constructor.
Upvotes: 3