-3

I have this code:

namespace Nop.Plugin.MostViewed
{
    public class MostViewCustom : BasePlugin, IWidgetPlugin
    {
        private readonly MVPObjectContext _context;

        public MostViewCustom(MVPObjectContext context)
        {
            this._context = context;
        }
    }
}

And it's giving me the following error:

Error CS7036 There is no argument given that corresponds to the required formal parameter 'nameOrConnectionString' of 'BasePlugin.BasePlugin(string)' Nop.Plugin.MostViewed

What's wrong with the code?

fhcimolin
  • 616
  • 1
  • 8
  • 27

2 Answers2

3

You need to call the base constructor, like so:

const string nameOrConnectionString = "???";
public MostViewCustom(MVPObjectContext context)
    : base(nameOrConnectionString) // <-- magic here
{
    this._context = context;
}

Next time, please place your code in a code block in your question, so it's easier to help you.

Jesse de Wit
  • 3,867
  • 1
  • 20
  • 41
0

If you are use nopCommerce than you need to two class for plugin.

  1. DbContext Class
  2. Plugin Class

MostViewObjectContext.cs

namespace Nop.Plugin.MostViewed
{
  public class MostViewObjectContext: DbContext, IDbContext
  {
    public MostViewObjectContext(string nameOrConnectionString) : base(nameOrConnectionString) { }
  protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
     Database.SetInitializer<MostViewObjectContext>(null);
     modelBuilder.Configurations.Add(new YourTableMappingClass());
    }
    public new IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity
    {
        return base.Set<TEntity>();
    }

    public IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params object[] parameters) where TEntity : BaseEntity, new()
    {
        throw new NotImplementedException();
    }
     public string CreateDatabaseScript()
    {
        return ((IObjectContextAdapter)this).ObjectContext.CreateDatabaseScript();
    }
    //Other all methods like  Install() and Uninstall()
  }
}

MostViewPlugin.cs

namespace Nop.Plugin.MostViewed
{
     public class MostViewedPlugin : BasePlugin, IWidgetPlugin
     {
      // Write code for IList<string> GetWidgetZones(),GetConfigurationPageUrl(), GetPublicViewComponent(string widgetZone, out string viewComponentName), Install() and Uninstall()
     }
}
Kalpesh Boghara
  • 418
  • 3
  • 22