je tente de créer une fonction statique dans Nop.Services.Customers.CustomerService pour obteniri ne peut pas créer une méthode statique dans Nop.Services.Customers.CustomerService
liste des clientsdans la base de données de NOP. Je veux appeler cette fonction dans une console externe
Application. Mais la classe CustomerService ne contient pas le constructeur par défaut.
Veuillez voir le code du constructeur.
#region Ctor
/// <summary>
/// Ctor
/// </summary>
/// <param name="cacheManager">Cache manager</param>
/// <param name="customerRepository">Customer repository</param>
/// <param name="customerRoleRepository">Customer role repository</param>
/// <param name="customerAttributeRepository">Customer attribute repository</param>
/// <param name="encryptionService">Encryption service</param>
/// <param name="newsLetterSubscriptionService">Newsletter subscription service</param>
/// <param name="rewardPointsSettings">Reward points settings</param>
/// <param name="customerSettings">Customer settings</param>
/// <param name="eventPublisher"></param>
public CustomerService(ICacheManager cacheManager,
IRepository<Customer> customerRepository,
IRepository<CustomerRole> customerRoleRepository,
IRepository<CustomerAttribute> customerAttributeRepository,
IEncryptionService encryptionService, INewsLetterSubscriptionService newsLetterSubscriptionService,
RewardPointsSettings rewardPointsSettings, CustomerSettings customerSettings,
IEventPublisher eventPublisher)
{
_cacheManager = cacheManager;
_customerRepository = customerRepository;
_customerRoleRepository = customerRoleRepository;
_customerAttributeRepository = customerAttributeRepository;
_encryptionService = encryptionService;
_newsLetterSubscriptionService = newsLetterSubscriptionService;
_rewardPointsSettings = rewardPointsSettings;
_customerSettings = customerSettings;
_eventPublisher = eventPublisher;
}
#endregion
Et Fileds est l'erreur lorsque vous essayez d'appeler dans la fonction statique.
S'il vous plaît voir les champs
#region Fields
private readonly IRepository<Customer> _customerRepository;
private readonly IRepository<CustomerRole> _customerRoleRepository;
private readonly IRepository<CustomerAttribute> _customerAttributeRepository;
private readonly IRepository<FileUpload> _fileuploadRepository;
private readonly IEncryptionService _encryptionService;
private readonly ICacheManager _cacheManager;
private readonly INewsLetterSubscriptionService _newsLetterSubscriptionService;
private readonly RewardPointsSettings _rewardPointsSettings;
private readonly CustomerSettings _customerSettings;
private readonly IEventPublisher _eventPublisher;
#endregion
créer un défaut dans la classe CustomerService.
public CustomerService()
{
}
et créer de nouvelles fonctions dans CustomerService
public virtual List<Customer> GetClients()
{
var _cust = _customerRepository.Table;
return _cust.ToList();
}
et appeler cette fonction dans une application console externe
private static CustomerService _customerService = new CustomerService();
static void Main(string[] args)
{
List<Customer> cust = _customerService.GetClients();
ThreadStart start = new ThreadStart(ProcessMails);
thread = new Thread(start);
ProcessStatus = 1;
thread.Start();
}
Mais quand j'appelle cette fonction, il est montre l'erreur nulle.
Il est impossible de créer une fonction dans Nop.Core et faire appel à une application externe?
Aidez-nous s'il vous plaît.
Afficher l'erreur ** exact **. – Blorgbeard