Ling.Audit by Jing Ling
Nuget / site data
Details
Info
info
Name: Ling.Audit
A source generator for audit properties.
Author: Jing Ling
NuGet: https://www.nuget.org/packages/Ling.Audit/
You can find more details at https://github.com/ling921/dotnet-lib/
Original Readme
note
Introduction
This is a dotnet library repository that contains the following public libraries
Project | Package | Description |
---|---|---|
Ling.Cache | A cache library that can easily use memory cache or redis cache. | |
Ling.Audit | A source generator to generate audit properties. | |
Ling.EntityFrameworkCore | An extension library of Microsoft.EntityFrameworkCore . | |
Ling.EntityFrameworkCore.Audit | An extension library that can automatically record entity changes of Microsoft.EntityFrameworkCore . | |
Ling.Blazor | A library for Blazor. | |
Ling.Blazor.Authentication | A library that provides JWT authentication for Blazor applications. |
License
This project is licensed under the Apache-2.0
About
note
Generating audit data from class implementation of interfaces
How to use
Example ( source csproj, source files )
- CSharp Project
- Program.cs
- Person.cs
This is the CSharp Project that references Ling.Audit
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ling.Audit" Version="1.1.0" />
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>
This is the use of Ling.Audit in Program.cs
// See https://aka.ms/new-console-template for more information
using LingDemo;
Console.WriteLine("Hello, World!");
var p = new Person();
await Task.Delay(2000);
p.FirstName = "Andrei";
p.LastName = "Ignat";
Console.WriteLine(p.CreationTime);
Console.WriteLine(p.LastModificationTime);
This is the use of Ling.Audit in Person.cs
using Ling.Audit;
namespace LingDemo;
partial class Person :IFullAudited<Guid>
{
public int ID { get; set; }
public string FirstName { get; set; }= string.Empty;
public string LastName { get; set; } = string.Empty;
}
Generated Files
Those are taken from $(BaseIntermediateOutputPath)\GX
- Person.g.cs
// <auto-generated/>
#nullable enable annotations
#nullable disable warnings
namespace LingDemo
{
partial class Person
{
/// <summary>
/// Gets or sets the creation time of this entity.
/// </summary>
public virtual global::System.DateTimeOffset CreationTime { get; set; }
/// <summary>
/// Gets or sets the creator Id of this entity.
/// </summary>
public virtual global::System.Nullable<global::System.Guid> CreatorId { get; set; }
/// <summary>
/// Gets or sets the last modification time of this entity.
/// </summary>
public virtual global::System.Nullable<global::System.DateTimeOffset> LastModificationTime { get; set; }
/// <summary>
/// Gets or sets the last modifier Id of this entity.
/// </summary>
public virtual global::System.Nullable<global::System.Guid> LastModifierId { get; set; }
/// <summary>
/// Gets or sets whether this entity is soft deleted.
/// </summary>
public virtual global::System.Boolean IsDeleted { get; set; }
/// <summary>
/// Gets or sets the deletion time of this entity.
/// </summary>
public virtual global::System.Nullable<global::System.DateTimeOffset> DeletionTime { get; set; }
/// <summary>
/// Get or set the deleter Id of this entity.
/// </summary>
public virtual global::System.Nullable<global::System.Guid> DeleterId { get; set; }
}
}
Usefull
Download Example (.NET C# )
Share Ling.Audit
https://ignatandrei.github.io/RSCG_Examples/v2/docs/Ling.Audit