ninject

Ninject Binding

纵饮孤独 提交于 2019-12-18 12:44:20
问题 How do bind my interface to a concrete class in a different assembly? I have the following projects in my solution: Foo.Data Foo.Domain In Structure Map I add my two assembly names to the StructureMap.config file and a then using the PluginFamily and Pluggable attributes map my interfaces to my concrete class'. How can accomplish the same thing with Ninject? 回答1: I'll make a couple of assumptions here. You have an interface named IBar in your Foo.Domain project and you have a concrete class

IoC, AOP and more

本秂侑毒 提交于 2019-12-18 11:58:01
问题 What is an IoC container? What is an IoC/DI framework? Why do we need a framework for IoC/DI? Is there any relationship between IoC/DI and AOP? What is Spring.net/ninject with respect to IoC and AOP? 回答1: JMSA, James Kovacs wrote a fantastic article which covers many of your questions I would recommend reading it Here Spring.Net, Ninject, Unity, Castle Windsor, Autofac are all IOC containers which are configurable in different ways, many of them do also support AOP. Frameworks for IOC/DI are

Multitenancy with Fluent nHibernate and Ninject. One Database per Tenant

我只是一个虾纸丫 提交于 2019-12-18 11:42:22
问题 I'm building a multi-tenant web application where for security concerns, we need to have one instance of the database per tenant. So I have a MainDB for authentication and many ClientDB for application data. I am using Asp.net MVC with Ninject and Fluent nHibernate. I have already setup my SessionFactory/Session/Repositories using Ninject and Fluent nHibernate in a Ninject Module at the start of the application. My sessions are PerRequestScope, as are repositories. My problem is now I need to

How-to inject the Entity Framework DbContext into the ConfigurationBasedRepository of SharpRepository

倾然丶 夕夏残阳落幕 提交于 2019-12-18 11:13:12
问题 I really would like to use SharpRepository together with Ninject, but I do not understand how to configure Ninject to share the Entity Framework DbContext between the repositories. I am using Entity Framework version 5 and Ninject version 3. Currently I am using Ef5Repository in my source code, but I want to replace it with ConfigurationBasedRepository . But I cannot figure out how to pass (or inject) the EF DbContext to the repositories. Example (current state): using SharpRepository

How-to inject the Entity Framework DbContext into the ConfigurationBasedRepository of SharpRepository

浪尽此生 提交于 2019-12-18 11:13:11
问题 I really would like to use SharpRepository together with Ninject, but I do not understand how to configure Ninject to share the Entity Framework DbContext between the repositories. I am using Entity Framework version 5 and Ninject version 3. Currently I am using Ef5Repository in my source code, but I want to replace it with ConfigurationBasedRepository . But I cannot figure out how to pass (or inject) the EF DbContext to the repositories. Example (current state): using SharpRepository

What does WebActivator do?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 10:59:28
问题 This code was generated for me after added entity framework code-first for SQL Server CE using NuGet. They did no changes to any other file. The file SQLCEEntityFramework.cs was created and placed in App_Start folder. Does this mean it automatically gets executed or something? The same thing happened when I added Ninject for MVC 3. No code was added to the global.ascx file so I have no idea if its plug and play or I have to configure something. [assembly: WebActivator

What does WebActivator do?

徘徊边缘 提交于 2019-12-18 10:58:59
问题 This code was generated for me after added entity framework code-first for SQL Server CE using NuGet. They did no changes to any other file. The file SQLCEEntityFramework.cs was created and placed in App_Start folder. Does this mean it automatically gets executed or something? The same thing happened when I added Ninject for MVC 3. No code was added to the global.ascx file so I have no idea if its plug and play or I have to configure something. [assembly: WebActivator

What is Ninject and when do you use it?

假如想象 提交于 2019-12-18 10:10:46
问题 I have been helping a few friends on a project and there is a class that uses Ninject. I am fairly new to C# and I have no idea what that class is doing, which is why I need to understand Ninject. Can anyone explain what Ninject is and when does one use it(with example if possible)? Or if you can point to some links that would be great too. I tried this question: Ninject tutorials/documentations? but it didn't really help a beginner like me. 回答1: Ninject is dependency injector for .NET,

MVC5, WebAPI2 and Ninject Parameterless constructor error

*爱你&永不变心* 提交于 2019-12-18 08:55:51
问题 So I have the exact opposite problem as MVC5, Web API 2 and Ninject I have a new MVC5/WebAPI2 project, that has both "Controller"s and "ApiControllers". I'm using the latest unstable version of Ninject.Web.WebAPI with no code changes to NinjectDependencyResolve.cs and Ninject.WebCommom.cs (besides binding my dependency) the ApiController's constructor injection works. However, when I call a MVC Controller I get: No parameterless constructor defined for this object. 回答1: The issue is you need

Getting 'Context is not constructible. Add a default constructor or provide an implementation of IDbContextFactory."

ぐ巨炮叔叔 提交于 2019-12-18 07:35:02
问题 I am getting this error when I try to use code first migrations. My context has a constructor with the connection name. public class VeraContext : DbContext, IDbContext { public VeraContext(string NameOrConnectionStringName = "VeraDB") : base(NameOrConnectionStringName) { } public IDbSet<User> Users { get; set; } public IDbSet<Product> Products { get; set; } public IDbSet<IntCat> IntCats { get; set; } } This connection name is injected with ninject when the project runs, I have also specified