Base solution for your next web application
Open Closed

Repository extension registration error #4689


User avatar
0
abdourahmani created

Hi !

I followed this link to implement an extension on IRepository.[https://gist.github.com/hikalkan/74f624c0b42c78fb1619e92b3d1972f8])

But I get this error when instantiation the service class

ERROR 2018-02-14 10:54:38,335 [17   ] Mvc.ExceptionHandling.AbpExceptionFilter - Can't create component 'Lbi.RapproDab.AppService.Session.Close.CloseSessionAppService' as it has dependencies to be satisfied.

'Lbi.RapproDab.AppService.Session.Close.CloseSessionAppService' is waiting for the following dependencies:
- Service 'Abp.Domain.Repositories.IRepository`2[[Lbi.RapproDab.AppEntities.HisAcctTrans, Lbi.RapproDab.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.

Castle.MicroKernel.Handlers.HandlerException: Can't create component 'Lbi.RapproDab.AppService.Session.Close.CloseSessionAppService' as it has dependencies to be satisfied.

Here is my extension code

public static void Insert<TEntity, 
            TPrimaryKey>(this IRepository<TEntity, TPrimaryKey> repository, IEnumerable<TEntity> entities)
            where TEntity : class, IEntity<TPrimaryKey>, new()
        {
            var type = Type.GetType("Lbi.RapproDab.RepositoryHelpers, Lbi.RapproDab.EntityFrameworkCore");

            var bulkInsertMethod = type.GetMethod("BulkInsert", BindingFlags.Static | BindingFlags.Public);

            var genericMethod = bulkInsertMethod.MakeGenericMethod(typeof(TEntity), typeof(TPrimaryKey));

            genericMethod.Invoke(null, new object[] { repository, entities });
        }

If I really have to register IRepository, what will be the implementation name (YYYYYYYYY)?

IocManager.Register(typeof(IRepository<,>), typeof(YYYYYYYYY<,>), DependencyLifeStyle.Transient);

2 Answer(s)
  • User Avatar
    0
    abdourahmani created

    Sorry !

    Problem solved.

    I did put the Dbset property of this entity in the context class.

    Regards, Abdourahmani

  • User Avatar
    0
    ismcagdas created
    Support Team

    Great :)