【问题标题】:Logging every time a database table is updated每次更新数据库表时记录
【发布时间】:2019-03-13 19:13:00
【问题描述】:

好的,所以在 nopcommerce 中我们有客户表。

private readonly IRepository<Customer> _customerRepository;

是否有某种方式来监听或挂钩事件,所以每次更新数据库表时,我都可以设置一个触发的断点。

这真的可以帮助我找出问题出在哪里,在哪里创建了过多的访客帐户。

谢谢

【问题讨论】:

  • 我不知道 nopcommerce 但通常你可以使用触发器codeproject.com/Articles/38808/…
  • NopCommerce 有一个 eventPublisher,您可以为您想要的每个实体编写自己的 eventListener。

标签: c# sql-server database nopcommerce


【解决方案1】:

没有针对来宾客户的特定挂钩,但是您可以通过两种方法实现。 首先,使用事件,nopCommerce 提供事件类型来执行发布逻辑。 因此,无论何时插入或更新记录,您都会收到有关您的自定义事件的电话。

IConsumer<EntityInserted<Customer>>

第二种方法是,为客户方法实现动作过滤器。

好读:Exposing and Handling Events

【讨论】:

  • 很高兴能帮到你:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-01-13
  • 2016-01-15
  • 2021-09-14
  • 2018-12-10
  • 1970-01-01
  • 1970-01-01
  • 2015-05-06
相关资源
最近更新 更多