Quantcast
Channel: patterns & practices: Project Silk
Viewing all articles
Browse latest Browse all 93

New Post: How to use Unity Block solve the type that contain parameter?

$
0
0
Hi,

Take a look at the code.

public class UnitedExportDbContext : DbContext, IUnitOfWork
{
    //public string connectionString="data source=.\\SQLExpress;Integrated Security=SSPI;Initial Catalog=UnitedExportDb";
    public UnitedExportDbContext(string connectionString)
        : base(connectionString)
    {

    }
With Prism I can do like the line below

container.RegisterType<IUnitOfWork, ReservationContext>(new ContainerControlledLifetimeManager(), new InjectionConstructor("FasterTableContext"));

Because of we register the types like following way.
<type type="UnitedExport.Data.IRepositoryInitializer, UnitedExport.Data" mapTo="UnitedExport.Data.Sql.RepositoryInitializer, UnitedExport.Data.Sql">
<lifetime type="perRequest" />
    </type>
    <type type="UnitedExport.Data.IUnitOfWork, UnitedExport.Data" mapTo="UnitedExport.Data.Sql.UnitedExportDbContext, UnitedExport.Data.Sql">
      <lifetime type="perRequest" />
    </type>
I create the database like following code.

public virtual void Execute(ProvisioningRequestObj obj)
    {
        var repositoryInitializer = ServiceLocator.Current.GetInstance<IRepositoryInitializer>();
        repositoryInitializer.Initialize();     
    }
I got this error messages

{"The type String cannot be constructed. You must configure the container to supply this value."}

What I need is that the dynamic not lives within config file

Viewing all articles
Browse latest Browse all 93

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>