Plugin repository exception

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi all,

i have a weird error(again) and i cannot figure out what could be.

in my controller i cannot get the record repository working.
my entities and the repo table is also giving an exception.


my dependicy registrar seems to be okay, also my record, map and context.


namespace Nop.Plugin.Misc.EmagMarketplace.Infrastructure
{
    public class DependencyRegistrar : IDependencyRegistrar
    {
        private const string CONTEXT_NAME = "nop_object_context_emagmarketplace";

        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            //data context
            this.RegisterPluginDataContext<EmagMarketplaceRecordObjectContext>(builder, CONTEXT_NAME);

            //override required repository with our custom context
            builder.RegisterType<EfRepository<EmagMarketplaceRecord>>()
                .As<IRepository<EmagMarketplaceRecord>>()
                .WithParameter(ResolvedParameter.ForNamed<IDbContext>(CONTEXT_NAME))
                .InstancePerLifetimeScope();

        }

        public int Order
        {
            get { return 1; }
        }
    }
}




namespace Nop.Plugin.Misc.EmagMarketplace.Domain
{
    public class EmagMarketplaceRecord : BaseEntity
    {
        public int product_id { get; set; }
        public int emag_category_id { get; set; }
        public string name { get; set; }
        public bool SendWebShopImages { get; set; }
        public string part_number { get; set; }
        public string description { get; set; }
        public string brand { get; set; }
        public string url { get; set; }
        public int status { get; set; }
        public decimal sale_price { get; set; }
        public decimal min_sale_price { get; set; }
        public decimal max_sale_price { get; set; }
        public int availability { get; set; }
        public int stocknr { get; set; }
        public int handling_time { get; set; }
        public int vat_id { get; set; }
        public int firstcharacteristicsid { get; set; }
        public DateTime inserted_dtm { get; set; }
    }
}




namespace Nop.Plugin.Misc.EmagMarketplace.Data
{
    public class EmagMarketplaceRecordMap : EntityTypeConfiguration<EmagMarketplaceRecord>
    {
        public EmagMarketplaceRecordMap()
        {
            ToTable("EmagMarketplace");
            HasKey(m => m.Id);

            Property(m => m.product_id);
            Property(m => m.emag_category_id);
            Property(m => m.name);
            Property(m => m.SendWebShopImages);
            Property(m => m.part_number);
            Property(m => m.description);
            Property(m => m.brand);
            Property(m => m.url);
            Property(m => m.status);
            Property(m => m.sale_price);
            Property(m => m.min_sale_price);
            Property(m => m.max_sale_price);
            Property(m => m.availability);
            Property(m => m.stocknr);
            Property(m => m.handling_time);
            Property(m => m.vat_id);
            Property(m => m.firstcharacteristicsid);
            Property(m => m.inserted_dtm);
        }
    }
}



namespace Nop.Plugin.Misc.EmagMarketplace.Data
{
    public class EmagMarketplaceRecordObjectContext : DbContext, IDbContext
    {
        #region Properties

        /// <summary>
        /// Gets or sets a value indicating whether proxy creation setting is enabled (used in EF)
        /// </summary>
        public virtual bool ProxyCreationEnabled
        {
            get
            {
                return this.Configuration.ProxyCreationEnabled;
            }
            set
            {
                this.Configuration.ProxyCreationEnabled = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether auto detect changes setting is enabled (used in EF)
        /// </summary>
        public virtual bool AutoDetectChangesEnabled
        {
            get
            {
                return this.Configuration.AutoDetectChangesEnabled;
            }
            set
            {
                this.Configuration.AutoDetectChangesEnabled = value;
            }
        }

        #endregion

        public EmagMarketplaceRecordObjectContext(string nameOrConnectionString) : base(nameOrConnectionString) { }

        #region Implementation of IDbContext

        #endregion

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new EmagMarketplaceRecordMap());

            base.OnModelCreating(modelBuilder);
        }

        public string CreateDatabaseInstallationScript()
        {
            return ((IObjectContextAdapter)this).ObjectContext.CreateDatabaseScript();
        }

        public void Install()
        {
            //It's required to set initializer to null (for SQL Server Compact).
            //otherwise, you'll get something like "The model backing the 'your context name' context has changed since the database was created. Consider using Code First Migrations to update the database"
            Database.SetInitializer<EmagMarketplaceRecordObjectContext>(null);

            Database.ExecuteSqlCommand(CreateDatabaseInstallationScript());
            SaveChanges();
        }

        public void Uninstall()
        {
            var tableName = this.GetTableName<EmagMarketplaceRecord>();
            this.DropPluginTable(tableName);
        }

        public new IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity
        {
            return base.Set<TEntity>();
        }

        public System.Collections.Generic.IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params object[] parameters) where TEntity : BaseEntity, new()
        {
            throw new System.NotImplementedException();
        }

        public System.Collections.Generic.IEnumerable<TElement> SqlQuery<TElement>(string sql, params object[] parameters)
        {
            throw new System.NotImplementedException();
        }

        public int ExecuteSqlCommand(string sql, bool doNotEnsureTransaction = false, int? timeout = null, params object[] parameters)
        {
            throw new System.NotImplementedException();
        }

        IDbSet<TEntity> IDbContext.Set<TEntity>()
        {
            throw new NotImplementedException();
        }

        int IDbContext.SaveChanges()
        {
            throw new NotImplementedException();
        }

        IList<TEntity> IDbContext.ExecuteStoredProcedureList<TEntity>(string commandText, params object[] parameters)
        {
            throw new NotImplementedException();
        }

        IEnumerable<TElement> IDbContext.SqlQuery<TElement>(string sql, params object[] parameters)
        {
            throw new NotImplementedException();
        }

        int IDbContext.ExecuteSqlCommand(string sql, bool doNotEnsureTransaction, int? timeout, params object[] parameters)
        {
            throw new NotImplementedException();
        }

        void IDbContext.Detach(object entity)
        {
            throw new NotImplementedException();
        }
    }
}


What else can i check? does anyone sees the issue?
driving me crazy :)
6 years ago
https://www.dropbox.com/s/a0y7wh86vro9gdb/exception.jpg?dl=0
6 years ago
try removing throw new NotImplementedException(); from the objectcontext class to see if that has anything to do with it.
6 years ago
oh now i see, i had the set there 2 times. how did that got there? pff
thanks man!
6 years ago
it gets written out when the methods are created by VS.
6 years ago
anyway thanks! tiring Friday :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.