1 Star 0 Fork 59

Alex950808 / Zxw.Framework.NetCore

forked from 旺仔 / Zxw.Framework.NetCore 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Zxw.Framework.NetCore

基于EF Core的Code First模式的DotNetCore快速开发框架

Nuget [最新版本:2.1.3-preview2-t007bc0fad]

Zxw.Framework.NetCore

  • Install-Package Zxw.Framework.NetCore -Version 2.1.3-preview2-t007bc0fad
  • dotnet add package Zxw.Framework.NetCore --version 2.1.3-preview2-t007bc0fad

开发环境

  • VS2017 / VS Code
  • .net core 2.2

支持的数据库

日志组件

  • log4net

DI组件

缓存组件使用

本项目采用的AOP中间件 :AspectCore-Framework

  • MemoryCacheAttribute :基于MemoryCache的缓存拦截组件
  • RedisCacheAttribute :基于Redis的缓存拦截组件

如何使用:

public interface ITutorClassTypeRepository:IRepository<TutorClassType, Int32>
{
    [MemoryCache]//使用MemoryCache,缓存有效时间默认10分钟
    IList<TutorClassType> GetByMemoryCached(Expression<Func<TutorClassType, bool>> where = null);

    [RedisCache(Expiration = 5)]//使用Redis,缓存有效时间为5分钟
    IList<TutorClassType> GetByRedisCached(Expression<Func<TutorClassType, bool>> where = null);
}

示例

.net framework版本地址

项目说明

更新日志

2019/04/25

  • 1.修改缓存拦截器默认key格式为:{namespace}{class}{method}{参数值hashcode}
  • 2.缓存拦截器添加对Task<>类型的支持

2019/04/18

  • 1.删除触发器功能...
  • 2.实现多数据库上下文。用法:
    //注入数据库上下文
    services.AddDbContextFactory(factory =>
    {
        factory.AddDbContext<PostgreSQLDbContext>("db1", new DbContextOption(){ConnectionString = "User ID=postgres;Password=123456;Host=localhost;Port=5432;Database=ZxwPgDemo;Pooling=true;" });
        factory.AddDbContext<SqlServerDbContext>("db2", new DbContextOption() { ConnectionString = "" });
        factory.AddDbContext<MongoDbContext>("db3", new DbContextOption() { ConnectionString = "" });
    });


    //获取
    public class TestController
    {
        public IDbContextCore DbContext1 { get; set; }
        public IDbContextCore DbContext2 { get; set; }
        public IDbContextCore DbContext3 { get; set; }

        public TestController(DbContextFactory factory)
        {
            DbContext1 = factory.GetDbContext("db1");
            DbContext2 = factory.GetDbContext("db2");
            DbContext3 = factory.GetDbContext("db3");
        }

        public void Run()
        {
            var db = DbContext1.GetDatabase();
            Console.WriteLine();
        }
    }
  • 3.多数据库上下文支持属性注入,用法如下:(具体请参考单元测试)
public class TestRepository: BaseRepository<MongoModel, ObjectId>, IMongoRepository
    {
        [FromDbContextFactory("db1")]
        public IDbContextCore DbContext1 { get; set; }
        [FromDbContextFactory("db2")]
        public IDbContextCore DbContext2 { get; set; }
        [FromDbContextFactory("db3")]
        public IDbContextCore DbContext3 { get; set; }



        public void Run()
        {
            Console.WriteLine("Over!");
        }

        public TestRepository(IDbContextCore dbContext) : base(dbContext)
        {
        }
    }

2018/09/24

2018/08/26

  • 1.添加自定义视图分页查询,数据库分页,目前只支持sqlserver
  • 2.update packages

2018/07/06 合并dev分支到master

  • 1.添加EFCore直接返回DataTable功能
  • 2.DBFirst功能,目前仅支持SQL Server、MySQL、NpgSQL三种数据库。根据已存在的数据表直接生成实体代码,详见CodeGenerator
  • 3.添加单元测试项目,并完成对以上两点新功能的测试
  • 4.引入IOC容器Aspectcore.Injector,详见AspectCoreContainer.cs

开源协议

  • 本开源项目遵守MIT开源协议,请保留原作者出处。
MIT License Copyright (c) 2017 旺仔 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于EF Core的Code First模式的DotNetCore快速开发框架,其中包括DBContext、IOC组件autofac和AspectCore.Injector、代码生成器(也支持DB First)、基于AspectCore的memcache和Redis缓存组件,以及基于ICanPay的支付库和一些日常用的方法和扩展,当然还有demo。欢迎提交各种建议、意见和pr~ 展开 收起
C#
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/Alex950808/Zxw.Framework.NetCore.git
git@gitee.com:Alex950808/Zxw.Framework.NetCore.git
Alex950808
Zxw.Framework.NetCore
Zxw.Framework.NetCore
master

搜索帮助