0
zhongfang created
- ABP Framework version: v5.1.3
- UI type: Blazor (Server Side)
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
- Exception message and stack trace: no exception. and I can find the success in Serilog out put.
- Steps to reproduce the issue:"
- Insert into repository by code
Serilog.Log.Information("开始登记取消关注的情况。Open Id:" + openId);
ISubscribeUserRepository subscribeUserRepository = this.LazyServiceProvider.LazyGetRequiredService<ISubscribeUserRepository>();
if (subscribeUserRepository == null)
{
throw new Exception("没有找到 ISubscribeUserRepository。");
}
SubscribeUser subscribeUser = (await subscribeUserRepository.GetQueryableAsync()).FirstOrDefault(p => p.OpenId == openId && p.TenantId == tenantId);
if (subscribeUser == null)
{
subscribeUser = new SubscribeUser()
{
OpenId = openId,
Nick = "unknown",
UnSubscribedOn = DateTime.Now,
SubscribedTimes = 1,
UnSubscribedTimes = 1,
WeChatAppId = this.CurrentWeChatApp.WeChatApp.Result.Id,
TenantId = tenantId
};
subscribeUser = await subscribeUserRepository.InsertAsync(subscribeUser, autoSave: true);
Serilog.Log.Information("成功新增了取消关注的情况。Open Id:" + openId + ",创建时间:" + subscribeUser.CreationTime + "TenantId:" + tenantId);
}
else
{
subscribeUser.UnSubscribedOn = DateTime.Now;
subscribeUser.UnSubscribedTimes = subscribeUser.UnSubscribedTimes + 1;
await subscribeUserRepository.UpdateAsync(subscribeUser, autoSave: true);
Serilog.Log.Information("成功更新了取消关注的情况。Open Id:" + openId);
}
return true;
- In Serilog output, above operation of InsertAsync is success.
[23:11:16 INF] 开始登记取消关注的情况。Open Id:oZKzr0_vqPUa5e_DpS5gusyU7MGI
[23:11:16 DBG] Added 0 entity changes to the current audit log
[23:11:16 INF] 成功新增了取消关注的情况。Open Id:oZKzr0_vqPUa5e_DpS5gusyU7MGI,创建时间:2022/2/8 下午11:11:16TenantId:55eea838-1079-84e1-a90a-39fe122f8fb5
[23:11:16 DBG] Added 0 entity changes to the current audit log
- but I can not find the data in database which should has been insert async successfully.
3 Answer(s)
-
0
hi
Try to remove this https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs#L241
And check your logs to see if there is an error message.
-
0
Yes, I call InsertAsync in try catch.
I must InsertAsnyc first, then continue with throw exception.
How to do?
-
0
Try to call
SaveChangesAsync
subscribeUser = await subscribeUserRepository.InsertAsync(subscribeUser, autoSave: true); await UnitOfWorkManager.Current.SaveChangesAsync();