【发布时间】:2019-02-17 13:02:34
【问题描述】:
我正在使用Audit.Net (Audit.EntityFramework),我想知道如何保存实体的关系?
这是我的配置
Audit.Core.Configuration.Setup()
.UseEntityFramework(x => x
.AuditTypeMapper(typeName => typeof(AuditLog))
.AuditEntityAction<AuditLog>((ev, ent, auditEntity) =>
{
auditEntity.Table = ent.Table;
auditEntity.AuditDate = DateTime.UtcNow;
auditEntity.Action = ent.Action;
auditEntity._Changes = ent.Changes;
auditEntity._Entries = ev.GetEntityFrameworkEvent().Entries;
auditEntity.Success = ev.GetEntityFrameworkEvent().Success;
auditEntity._ColumnValues = ent.ColumnValues;
auditEntity._PrimaryKey = ent.PrimaryKey;
}));
考虑以下关系
public class Blog
{
public int Id { set; get; }
public string Title { set; get; }
public string AuthorName { set; get; }
public IList<Post> Posts { set; get; }
}
public class Post
{
public int Id { set; get; }
public string Title { set; get; }
public string Content { set; get; }
public virtual Blog Blog { set; get; }
}
我想知道删除Post 对象时Blog 的数据是什么。
【问题讨论】:
标签: entity-framework audit.net