中文| English
.Net 高可用、高效率的扩展库,希望对 .NET 开发者及爱好者带来便捷,告别996,远离ICU!!!
| 名称 | Nuget | 
|---|---|
| LBON.Consts | |
| LBON.Extensions | |
| LBON.Helper | |
| LBON.DependencyInjection | |
| LBON.EntityFrameworkCore | 
EntityFramework 底层实现和扩展类,包括创建审计字段、修改审计字段、删除审计字段和扩展字段的封装
    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; }
    }另外还添加ExtendableObjectExtensions扩展类去设置(SetData)、获取(GetData) ExtendableObject字段的值。封装IEfRepository,满足绝大部分EF操作
        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);在.NET CORE 中使用的话,可以引入LBON.EntityFrameworkCore库,里面封装了对IEfRepository的以来注入,并且实现了对IScopedDependency、ISingletonDependency、ITransientDependency继承类的自动批量注入,方便使用者注入自身服务。
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
{
}