SmartSql 3.8.10

SmartSql = MyBatis + Cache(Memory | Redis) + ZooKeeper + R/W Splitting +Dynamic Repository ....

Install-Package SmartSql -Version 3.8.10
dotnet add package SmartSql --version 3.8.10
paket add SmartSql --version 3.8.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

简介

SmartSql-Starter

Why

  • 拥抱 跨平台 DotNet Core,是时候了。
  • 高性能、高生产力,超轻量级的ORM。107kb

So SmartSql

  • TargetFrameworks: .NETFramework 4.6 & .NETStandard 2.0
  • SmartSql = MyBatis + Cache(Memory | Redis) + ZooKeeper + R/W Splitting + ......

主要特性

  • 1 ORM
    • 1.1 Sync
    • 1.2 Async
  • 2 XmlConfig & XmlStatement -> Sql
    • 2.1 SmartSqlMapConfig & SmartSqlMap (是的,你猜对了,和MyBatis一样,通过XML配置分离SQL。)
    • 2.2 Config Hot Update ->ConfigWatcher & Reload (配置文件热更新:当你需要修改Sql的时候,直接修改SqlMap配置文件,保存即可。)
  • 3 读写分离
    • 3.1 读写分离
    • 3.2 多读库 权重筛选 (配置多读库,根据读库权重选举读库)
  • 4 日志
    • 4.1 基于 Microsoft.Extensions.Logging.Abstractions (当你需要跟踪调试的时候一切都是那么一目了然)
  • 5 Dynamic Repository
    • 5.1 SmartSql.DyRepository (解放你的双手,你来定义仓储接口,我来实现数据库访问)
  • 6 查询缓存 (热数据缓存,一个配置轻松搞定)
    • 6.1 SmartSql.Cache.Memory
      • 6.1.1 Fifo
      • 6.1.2 Lru
    • 6.2 SmartSql.Cache.Redis
    • 6.3 缓存事务一致性
  • 7 分布式配置插件
    • 7.1 IConfigLoader (配置文件加载器)
    • 7.2 LocalFileConfigLoader (本地文件配置加载器)
      • 7.2.1 Load SmartSqlMapSource Xml
      • 7.3.1 Load SmartSqlMapSource Directory
    • 7.3 SmartSql.ZooKeeperConfig (ZooKeeper 分布式配置文件加载器)

安装 (NuGet)

Install-Package SmartSql

最佳实践

安装 SmartSql.DIExtension

Install-Package SmartSql.DIExtension

注入依赖

 services.AddSmartSql();
 services.AddRepositoryFactory();
 services.AddRepositoryFromAssembly((options) =>
 {
    options.AssemblyString = "SmartSql.Starter.Repository";
 });

定义仓储接口

    /// <summary>
    /// 属性可选: [SqlMap(Scope = "User")] ,不设置 则默认 Scope 模板:I{Scope}Repository
    /// 可传入自定义模板
    /// RepositoryBuilder builder=new RepositoryBuilder("I{Scope}DAL");
    /// </summary>
    public interface IUserRepository
    {
        /// <summary>
        /// 属性可选 [Statement(Execute = ExecuteBehavior.Auto,Id = "Query")]
        /// 默认 Execute:Auto ,自动判断 执行类型
        /// 默认 Id : 方法名
        /// </summary>
        /// <param name="reqParams"></param>
        /// <returns></returns>
        IEnumerable<User> Query(object reqParams);
        long GetRecord(object reqParams);
        User Get(object reqParams);
        long Insert(User entity);
        int Update(User entity);
        int Delete(User enttiy);
    }

尽情享用

    public class UserService
    {
        private readonly ISmartSqlMapper _smartSqlMapper;
        private readonly IUserRepository _userRepository;

        public UserService(
             ISmartSqlMapper smartSqlMapper
            , IUserRepository userRepository)
        {
            _smartSqlMapper = smartSqlMapper;
            _userRepository = userRepository;
        }

        public long Add(AddRequest request)
        {
            int existsNum = _userRepository.Exists(new { request.UserName });
            if (existsNum > 0)
            {
                throw new ArgumentException($"{nameof(request.UserName)} has already existed!");
            }
            return _userRepository.Add(new Entitiy.User
            {
                UserName = request.UserName,
                Password = request.Password,
                Status = Entitiy.UserStatus.Ok,
                CreationTime = DateTime.Now,
            });
        }

        public void UseTransaction()
        {
            try
            {
                _smartSqlMapper.BeginTransaction();
                //Biz();
                _smartSqlMapper.CommitTransaction();
            }
            catch (Exception ex)
            {
                _smartSqlMapper.RollbackTransaction();
                throw ex;
            }
        }
    }

文档地址

技术交流

点击链接加入QQ群【SmartSql 官方交流群】:604762592

简介

SmartSql-Starter

Why

  • 拥抱 跨平台 DotNet Core,是时候了。
  • 高性能、高生产力,超轻量级的ORM。107kb

So SmartSql

  • TargetFrameworks: .NETFramework 4.6 & .NETStandard 2.0
  • SmartSql = MyBatis + Cache(Memory | Redis) + ZooKeeper + R/W Splitting + ......

主要特性

  • 1 ORM
    • 1.1 Sync
    • 1.2 Async
  • 2 XmlConfig & XmlStatement -> Sql
    • 2.1 SmartSqlMapConfig & SmartSqlMap (是的,你猜对了,和MyBatis一样,通过XML配置分离SQL。)
    • 2.2 Config Hot Update ->ConfigWatcher & Reload (配置文件热更新:当你需要修改Sql的时候,直接修改SqlMap配置文件,保存即可。)
  • 3 读写分离
    • 3.1 读写分离
    • 3.2 多读库 权重筛选 (配置多读库,根据读库权重选举读库)
  • 4 日志
    • 4.1 基于 Microsoft.Extensions.Logging.Abstractions (当你需要跟踪调试的时候一切都是那么一目了然)
  • 5 Dynamic Repository
    • 5.1 SmartSql.DyRepository (解放你的双手,你来定义仓储接口,我来实现数据库访问)
  • 6 查询缓存 (热数据缓存,一个配置轻松搞定)
    • 6.1 SmartSql.Cache.Memory
      • 6.1.1 Fifo
      • 6.1.2 Lru
    • 6.2 SmartSql.Cache.Redis
    • 6.3 缓存事务一致性
  • 7 分布式配置插件
    • 7.1 IConfigLoader (配置文件加载器)
    • 7.2 LocalFileConfigLoader (本地文件配置加载器)
      • 7.2.1 Load SmartSqlMapSource Xml
      • 7.3.1 Load SmartSqlMapSource Directory
    • 7.3 SmartSql.ZooKeeperConfig (ZooKeeper 分布式配置文件加载器)

安装 (NuGet)

Install-Package SmartSql

最佳实践

安装 SmartSql.DIExtension

Install-Package SmartSql.DIExtension

注入依赖

 services.AddSmartSql();
 services.AddRepositoryFactory();
 services.AddRepositoryFromAssembly((options) =>
 {
    options.AssemblyString = "SmartSql.Starter.Repository";
 });

定义仓储接口

    /// <summary>
    /// 属性可选: [SqlMap(Scope = "User")] ,不设置 则默认 Scope 模板:I{Scope}Repository
    /// 可传入自定义模板
    /// RepositoryBuilder builder=new RepositoryBuilder("I{Scope}DAL");
    /// </summary>
    public interface IUserRepository
    {
        /// <summary>
        /// 属性可选 [Statement(Execute = ExecuteBehavior.Auto,Id = "Query")]
        /// 默认 Execute:Auto ,自动判断 执行类型
        /// 默认 Id : 方法名
        /// </summary>
        /// <param name="reqParams"></param>
        /// <returns></returns>
        IEnumerable<User> Query(object reqParams);
        long GetRecord(object reqParams);
        User Get(object reqParams);
        long Insert(User entity);
        int Update(User entity);
        int Delete(User enttiy);
    }

尽情享用

    public class UserService
    {
        private readonly ISmartSqlMapper _smartSqlMapper;
        private readonly IUserRepository _userRepository;

        public UserService(
             ISmartSqlMapper smartSqlMapper
            , IUserRepository userRepository)
        {
            _smartSqlMapper = smartSqlMapper;
            _userRepository = userRepository;
        }

        public long Add(AddRequest request)
        {
            int existsNum = _userRepository.Exists(new { request.UserName });
            if (existsNum > 0)
            {
                throw new ArgumentException($"{nameof(request.UserName)} has already existed!");
            }
            return _userRepository.Add(new Entitiy.User
            {
                UserName = request.UserName,
                Password = request.Password,
                Status = Entitiy.UserStatus.Ok,
                CreationTime = DateTime.Now,
            });
        }

        public void UseTransaction()
        {
            try
            {
                _smartSqlMapper.BeginTransaction();
                //Biz();
                _smartSqlMapper.CommitTransaction();
            }
            catch (Exception ex)
            {
                _smartSqlMapper.RollbackTransaction();
                throw ex;
            }
        }
    }

文档地址

技术交流

点击链接加入QQ群【SmartSql 官方交流群】:604762592

Release Notes

1. fix Enum val bug

Version History

Version Downloads Last updated
3.8.10 0 12/14/2018
3.8.8 67 12/5/2018
3.8.6 73 11/29/2018
3.8.5 42 11/29/2018
3.8.4 140 11/9/2018
3.8.2 167 10/30/2018
3.8.0 43 10/29/2018
3.7.16 152 10/26/2018
3.7.15 149 10/24/2018
3.7.15-rc4 37 10/24/2018
3.7.15-rc2 37 10/23/2018
3.7.13 61 10/22/2018
3.7.12 43 10/22/2018
3.7.11 59 10/21/2018
3.7.10 123 10/11/2018
3.7.9 62 10/10/2018
3.7.8 95 9/30/2018
3.7.6 61 9/28/2018
3.7.5 60 9/26/2018
3.7.3 75 9/26/2018
3.7.2 52 9/25/2018
3.7.1 52 9/25/2018
3.7.0 75 9/18/2018
3.7.0-pre6 48 9/17/2018
3.6.9 57 9/16/2018
3.6.8.2 57 9/12/2018
3.6.8.1 158 9/9/2018
3.6.7 144 9/7/2018
3.6.5 106 9/1/2018
3.6.4 74 8/28/2018
3.6.2 95 8/23/2018
3.6.1 289 8/13/2018
3.6.0 152 8/8/2018
3.6.0-rc2 74 8/7/2018
3.6.0-rc1 83 8/5/2018
3.6.0-pre9 77 8/5/2018
3.6.0-pre8 77 8/5/2018
3.6.0-pre6 78 8/4/2018
3.6.0-pre3 76 8/3/2018
3.6.0-pre1 106 8/3/2018
3.5.14 92 8/2/2018
3.5.13 79 8/2/2018
3.5.12 78 8/2/2018
3.5.11 77 8/2/2018
3.5.10 81 8/1/2018
3.5.9 78 8/1/2018
3.5.8 84 7/31/2018
3.5.5 83 7/31/2018
3.5.3 96 7/25/2018
3.5.2 74 7/25/2018
3.5.1 79 7/25/2018
3.5.0 77 7/24/2018
3.5.0-pre2 74 7/23/2018
3.5.0-pre1 72 7/21/2018
3.4.8 104 7/19/2018
3.4.6 88 7/19/2018
3.4.3 91 7/19/2018
3.4.2 96 7/18/2018
3.4.0 95 7/18/2018
3.3.18 105 7/13/2018
3.3.16 84 7/12/2018
3.3.12 100 7/12/2018
3.3.11 122 7/5/2018
3.3.10 105 7/4/2018
3.3.8 110 7/1/2018
3.3.6 125 6/26/2018
3.3.4 243 6/26/2018
3.3.3 100 6/25/2018
3.3.1 115 6/13/2018
3.2.0 121 6/11/2018
3.1.0 95 6/9/2018
3.0.1 101 6/4/2018
3.0.0 104 6/2/2018
3.0.0-rc93 86 6/1/2018
3.0.0-rc92 91 5/31/2018
3.0.0-rc91 77 5/30/2018
3.0.0-rc8 86 5/29/2018
3.0.0-rc6 98 5/28/2018
3.0.0-rc5 84 5/27/2018
3.0.0-rc4 89 5/18/2018
3.0.0-rc3 93 5/16/2018
3.0.0-pre8 96 5/15/2018
3.0.0-pre4 99 5/12/2018
3.0.0-pre3 94 5/8/2018
3.0.0-pre2 94 5/7/2018
3.0.0-pre1 97 5/6/2018
2.3.2 454 3/25/2018
2.3.0 249 3/24/2018
2.2.8 142 3/8/2018
2.2.6 134 3/6/2018
2.2.2 180 2/5/2018
2.2.1 223 12/27/2017
2.2.0.2 153 12/27/2017
2.2.0.1 176 11/8/2017
2.2.0 160 11/7/2017
2.2.0-preview 135 11/3/2017
2.1.0-preview2 112 11/3/2017
2.0.18.8 120 10/24/2017
2.0.18.6 149 10/13/2017
2.0.18.5 123 10/10/2017
2.0.18.2 120 10/8/2017
2.0.18 142 9/28/2017
2.0.16 148 9/19/2017
2.0.15 144 9/19/2017
2.0.13 141 9/18/2017
2.0.12 144 9/18/2017
2.0.8 120 9/14/2017
2.0.6 119 9/12/2017
2.0.5 154 9/1/2017
2.0.4 123 8/30/2017
2.0.3 160 8/21/2017
2.0.0 137 8/16/2017
2.0.0-preview3-final 125 8/16/2017
2.0.0-preview2-final 155 8/16/2017
1.8.8.2 132 8/16/2017
1.8.8.1 135 8/15/2017
1.8.6.1 168 8/14/2017
1.8.6 163 8/11/2017
1.8.5 132 8/10/2017
1.8.3 130 8/10/2017
1.8.2 131 8/10/2017
1.8.0 138 8/10/2017
1.7.8 128 8/9/2017
1.6.7 172 8/8/2017
1.6.6 226 7/24/2017
1.6.2 228 7/19/2017
1.5.9 198 7/11/2017
1.5.8.1 217 5/27/2017
1.5.8 180 5/25/2017
1.5.5 178 5/23/2017
1.5.3 175 5/22/2017
1.5.2 178 5/22/2017
1.5.0 176 5/20/2017
1.4.9 198 4/25/2017
1.4.8 186 4/25/2017
1.4.4 190 4/21/2017
1.4.3 174 4/20/2017
1.4.2 181 4/20/2017
1.3.1 152 4/18/2017
1.2.0 182 4/17/2017
1.1.0 180 4/13/2017
1.0.4 180 4/7/2017
1.0.2 187 4/3/2017