- Notifications
You must be signed in to change notification settings - Fork8
Lu Ban Of .Net - .NET 工匠辅助库。Net 高可用、高效率的扩展库,希望对 .NET 开发者及爱好者带来便捷,告别996,远离ICU!!!
License
NotificationsYou must be signed in to change notification settings
CacoCode-zz/LBON
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
中文|English
.Net 高可用、高效率的扩展库,希望对 .NET 开发者及爱好者带来便捷,告别996,远离ICU!!!
名称 | Nuget |
---|---|
LBON.Consts | |
LBON.Extensions | |
LBON.Helper | |
LBON.DependencyInjection | |
LBON.EntityFrameworkCore |
EntityFramework 底层实现和扩展类,包括创建审计字段、修改审计字段、删除审计字段和扩展字段的封装
publicclassFullAuditedEntity<TKey,TUser>:EntityBase<TKey>,ICreationAudited<TUser>,IModificationAudited<TUser>,IDeletionAudited<TUser>{publicTUserCreatorId{get;set;}publicDateTimeCreationTime{get;set;}publicTUserLastModifierId{get;set;}publicDateTime?LastModificationTime{get;set;}publicTUserDeleterId{get;set;}publicboolIsDeleted{get;set;}publicDateTime?DeletionTime{get;set;}}
另外还添加ExtendableObjectExtensions扩展类去设置(SetData)、获取(GetData) ExtendableObject字段的值。封装IEfRepository,满足绝大部分EF操作
IQueryable<TEntity>GetAll(paramsExpression<Func<TEntity,object>>[]propertySelectors);IQueryable<TEntity>GetAll(Expression<Func<TEntity,bool>>expression,paramsExpression<Func<TEntity,object>>[]propertySelectors);TEntityFind(TPrimaryKeyid);Task<TEntity>FindAsync(TPrimaryKeyid);TEntityGet(Expression<Func<TEntity,bool>>expression,paramsExpression<Func<TEntity,object>>[]propertySelectors);Task<TEntity>GetAsync(Expression<Func<TEntity,bool>>expression,paramsExpression<Func<TEntity,object>>[]propertySelectors);voidInsert(TEntityentity,boolautoSave=true);TaskInsertAsync(TEntityentity,boolautoSave=true);Task<TPrimaryKey>InsertAndGetIdAsync(TEntityentity,boolautoSave=true);voidInsertList(List<TEntity>entities,boolautoSave=true);TaskInsertListAsync(List<TEntity>entities,boolautoSave=true);voidUpdate(TEntityentity,boolautoSave=true);TaskUpdateAsync(TEntityentity,boolautoSave=true);voidUpdateList(IEnumerable<TEntity>entities);TaskUpdateListAsync(IEnumerable<TEntity>entities);voidDelete(TPrimaryKeyid,boolautoSave=true);TaskDeleteAsync(TPrimaryKeyid,boolautoSave=true);voidDelete(TEntityentity,boolautoSave=true);TaskDeleteAsync(TEntityentity,boolautoSave=true);voidHardDelete(TPrimaryKeyid,boolautoSave=true);TaskHardDeleteAsync(TPrimaryKeyid,boolautoSave=true);voidHardDelete(TEntityentity,boolautoSave=true);TaskHardDeleteAsync(TEntityentity,boolautoSave=true);
在.NET CORE 中使用的话,可以引入LBON.EntityFrameworkCore库,里面封装了对IEfRepository的以来注入,并且实现了对IScopedDependency、ISingletonDependency、ITransientDependency继承类的自动批量注入,方便使用者注入自身服务。
publicvoidConfigureServices(IServiceCollectionservices){services.ServiceRegister(Assembly.Load("AssemblyName"),Assembly.Load("AssemblyName"));}
// ScopedpublicinterfaceIProductService:IScopedDependency{}// SingletonpublicinterfaceIProductService:ISingletonDependency{}// TransientpublicinterfaceIProductService:ITransientDependency{}
About
Lu Ban Of .Net - .NET 工匠辅助库。Net 高可用、高效率的扩展库,希望对 .NET 开发者及爱好者带来便捷,告别996,远离ICU!!!
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published