Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions docs2/pages/documentations/audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ foreach(var entry in entries)
}

```
{% include component-try-it.html href='https://dotnetfiddle.net/AJVhpP' %}

## AutoSave Audit

Expand Down Expand Up @@ -64,6 +65,7 @@ audit.CreatedBy = "ZZZ Projects"; // Optional
ctx.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/BfkqWm' %}

***By using a different context***

Expand Down Expand Up @@ -94,6 +96,7 @@ audit.CreatedBy = "ZZZ Projects"; // Optional
oracleContext.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/wTwh77' %}

***Custom AuditEntry & Database First Approach***

Expand All @@ -116,7 +119,7 @@ using (var ctx = new Entities())
ctx.SaveChanges(audit);
}

public AuditEntry Import(Z.EntityFramework.Plus.AuditEntry entry)
public Static AuditEntry Import(Z.EntityFramework.Plus.AuditEntry entry)
{
var customAuditEntry = new AuditEntry
{
Expand All @@ -133,7 +136,7 @@ public AuditEntry Import(Z.EntityFramework.Plus.AuditEntry entry)
return customAuditEntry;
}

public AuditEntryProperty Import(Z.EntityFramework.Plus.AuditEntryProperty property)
public Static AuditEntryProperty Import(Z.EntityFramework.Plus.AuditEntryProperty property)
{
var customAuditEntry = new AuditEntryProperty
{
Expand All @@ -147,6 +150,7 @@ public AuditEntryProperty Import(Z.EntityFramework.Plus.AuditEntryProperty prope
}

```
{% include component-try-it.html href='https://dotnetfiddle.net/9XjCSM' %}

***Saving automatically by overriding SaveChanges & SaveChangesAsync***

Expand Down Expand Up @@ -206,6 +210,7 @@ using(var ctx = new EntityContext())
}

```
{% include component-try-it.html href='https://dotnetfiddle.net/TFf8aj' %}

***SQL Script (for Database First)***

Expand Down Expand Up @@ -284,6 +289,7 @@ public class EntitySimple : IEntitySimple
}

```
{% include component-try-it.html href='https://dotnetfiddle.net/QPcF2a' %}

**Example Enable DataAnnotations**

Expand Down Expand Up @@ -326,6 +332,7 @@ audit.Configuration.Include<IAuditable>();
ctx.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/8TbEdO' %}

## Exclude & Include Property

Expand Down Expand Up @@ -364,6 +371,7 @@ audit.Configuration.ExcludeProperty<IAuditable>(x =>
ctx.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/eHO1fP' %}

## Format Value

Expand Down Expand Up @@ -394,6 +402,7 @@ audit.Configuration.Format<OrderItem>(x => x.Price,
ctx.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/Of9Dbz' %}

## Ignore Events

Expand Down Expand Up @@ -430,6 +439,7 @@ audit.Configuration.IgnoreRelationshipDeleted = true;
ctx.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/Ya95EQ' %}

## Property Unchanged

Expand Down Expand Up @@ -458,6 +468,7 @@ audit.Configuration.IgnorePropertyUnchanged = false;
ctx.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/tYE0YR' %}

## Soft Add & Soft Delete

Expand Down Expand Up @@ -490,6 +501,7 @@ audit.Configuration.SoftDeleted<ISoftDelete>(x => x.IsDeleted);
ctx.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/OadxfN' %}

## Retrieve AuditEntries for specific item

Expand All @@ -512,6 +524,7 @@ using (var ctx = new TestContext())
}

```
{% include component-try-it.html href='https://dotnetfiddle.net/ETFLlO' %}

### Audit, AuditEntry & AuditEntryProperty

Expand Down Expand Up @@ -588,6 +601,7 @@ audit.Configuration.AuditEntryFactory = args =>
ctx.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/aVIC0C' %}

#### Custom Class

Expand Down Expand Up @@ -616,6 +630,7 @@ audit.Configuration.AuditEntryPropertyFactory = args =>
ctx.SaveChanges(audit);

```
{% include component-try-it.html href='https://dotnetfiddle.net/xazeGj' %}

#### Custom DbSet with AutoSave

Expand Down Expand Up @@ -683,6 +698,7 @@ public class CurrentContext : DbContext
}

```
{% include component-try-it.html href='https://dotnetfiddle.net/AREtca' %}

## Limitations

Expand Down Expand Up @@ -713,4 +729,4 @@ Here is an example of this issue: [Issues #8](https://github.com/zzzprojects/Ent

Need help getting started? [info@zzzprojects.com](mailto:info@zzzprojects.com)

We welcome all comments, ideas and suggestions to improve our library.
We welcome all comments, ideas and suggestions to improve our library.