Skip to content

Latest commit

 

History

History
144 lines (114 loc) · 6.94 KB

README.en.md

File metadata and controls

144 lines (114 loc) · 6.94 KB

Github Build Status nuget downloads License

中文| English

Lu Ban Of .Net - .NET Luban Craftsman Auxiliary Library

. Net 's high available, efficient expansion library hopes to bring convenience to .NET developers and enthusiasts, farewell to 996 and away from ICU!!!

Nuget

Name Nuget
LBON.Consts NuGet
LBON.Extensions NuGet
LBON.Helper NuGet
LBON.DependencyInjection NuGet
LBON.EntityFrameworkCore NuGet

Function Module

LBON.EntityFrameworkCore

EntityFramework underlying implementation and extension classes, including the encapsulation of creating auditing fields, modifying auditing fields, deleting auditing fields, and extended fields

    public class FullAuditedEntity<TKey,TUser>:EntityBase<TKey>, ICreationAudited<TUser>, IModificationAudited<TUser>, IDeletionAudited<TUser>
    {
        public TUser CreatorId { get; set; }
        public DateTime CreationTime { get; set; }
        public TUser LastModifierId { get; set; }
        public DateTime? LastModificationTime { get; set; }
        public TUser DeleterId { get; set; }
        public bool IsDeleted { get; set; }
        public DateTime? DeletionTime { get; set; }
    }

Also add the ExtendableObjectExtensions extension class to set the (SetData), get the (GetData) ExtendableObject field value. Enapsulate IEfRepository, for most EF operations

        IQueryable<TEntity> GetAll(params Expression<Func<TEntity, object>>[] propertySelectors);

        IQueryable<TEntity> GetAll(Expression<Func<TEntity, bool>> expression,
            params Expression<Func<TEntity, object>>[] propertySelectors);

        TEntity Find(TPrimaryKey id);

        Task<TEntity> FindAsync(TPrimaryKey id);

        TEntity Get(Expression<Func<TEntity, bool>> expression,
            params Expression<Func<TEntity, object>>[] propertySelectors);

        Task<TEntity> GetAsync(Expression<Func<TEntity, bool>> expression,
            params Expression<Func<TEntity, object>>[] propertySelectors);

        void Insert(TEntity entity, bool autoSave = true);

        Task InsertAsync(TEntity entity, bool autoSave = true);

        Task<TPrimaryKey> InsertAndGetIdAsync(TEntity entity, bool autoSave = true);

        void InsertList(List<TEntity> entities, bool autoSave = true);

        Task InsertListAsync(List<TEntity> entities, bool autoSave = true);

        void Update(TEntity entity, bool autoSave = true);

        Task UpdateAsync(TEntity entity, bool autoSave = true);

        void UpdateList(IEnumerable<TEntity> entities);

        Task UpdateListAsync(IEnumerable<TEntity> entities);

        void Delete(TPrimaryKey id, bool autoSave = true);

        Task DeleteAsync(TPrimaryKey id, bool autoSave = true);

        void Delete(TEntity entity, bool autoSave = true);

        Task DeleteAsync(TEntity entity, bool autoSave = true);

        void HardDelete(TPrimaryKey id, bool autoSave = true);

        Task HardDeleteAsync(TPrimaryKey id, bool autoSave = true);

        void HardDelete(TEntity entity, bool autoSave = true);

        Task HardDeleteAsync(TEntity entity, bool autoSave = true);

.When used in NET CORE , the LBON.EntityFrameworkCore library can be introduced that encapsulates the since - injection of IEfRepository and enables the automatic batch injection of the IScopedDependency、ISingletonDependency、ITransientDependency inheritance class to facilitate users to inject their own services.

public void ConfigureServices(IServiceCollection services)
{
    services.ServiceRegister(Assembly.Load("AssemblyName"), Assembly.Load("AssemblyName"));
}
// Scoped
public interface IProductService: IScopedDependency
{
}
// Singleton
public interface IProductService: ISingletonDependency
{
}
// Transient
public interface IProductService: ITransientDependency
{
}

LBON.Extensions

LBON.Helper

LBON.Consts