increase the default field(TenantId,IsActive) protected virtual void SetCreationAuditProperties(DbEntityEntry entry) { if (entry.Entity is IHasCreationTime) { entry.Cast<IHasCreationTime>().Entity.CreationTime = Clock.Now; }
if (entry.Entity is ICreationAudited)
{
entry.Cast<ICreationAudited>().Entity.CreatorUserId = AbpSession.UserId;
}
**if (entry.Entity is IMayHaveTenant)
{
entry.Cast<IMayHaveTenant>().Entity.TenantId = AbpSession.TenantId;
}
if (entry.Entity is IMustHaveTenant)
{
if (AbpSession.TenantId == null)
throw new DbEntityValidationException("Configuration.MultiTenancy.IsEnabled is true,but TenantId is null");
entry.Cast<IMustHaveTenant>().Entity.TenantId = AbpSession.TenantId.Value;
}
if (entry.Entity is IPassivable)
{
entry.Cast<IPassivable>().Entity.IsActive = true;
}**
}
1 Answer(s)
-
0
Hi,
I could not understand to your purpose. Can you write some detail? You want to enhance SetCreationAuditProperties method. There are some codes in AbpDbContext may do similar job: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.EntityFramework/EntityFramework/AbpDbContext.cs#L184">https://github.com/aspnetboilerplate/as ... xt.cs#L184</a>
Please create an issue about your idea with more detailed info: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/new">https://github.com/aspnetboilerplate/as ... issues/new</a>
Thank you.