SmartSql 3.8.12

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

Install-Package SmartSql -Version 3.8.12
dotnet add package SmartSql --version 3.8.12
paket add SmartSql --version 3.8.12
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.12 235 12/17/2018
3.8.8 115 12/5/2018
3.8.6 120 11/29/2018
3.8.5 74 11/29/2018
3.8.4 175 11/9/2018
3.8.2 259 10/30/2018
3.8.0 89 10/29/2018
3.7.16 326 10/26/2018
3.7.15 239 10/24/2018
3.7.15-rc4 79 10/24/2018
3.7.15-rc2 67 10/23/2018
3.7.13 97 10/22/2018
3.7.12 78 10/22/2018
3.7.11 94 10/21/2018
3.7.10 154 10/11/2018
3.7.9 91 10/10/2018
3.7.8 200 9/30/2018
3.7.6 93 9/28/2018
3.7.5 89 9/26/2018
3.7.3 118 9/26/2018
3.7.2 83 9/25/2018
3.7.1 93 9/25/2018
3.7.0 116 9/18/2018
3.7.0-pre6 77 9/17/2018
3.6.9 86 9/16/2018
3.6.8.2 85 9/12/2018
3.6.8.1 242 9/9/2018
3.6.7 201 9/7/2018
3.6.5 145 9/1/2018
3.6.4 104 8/28/2018
3.6.2 128 8/23/2018
3.6.1 322 8/13/2018
3.6.0 186 8/8/2018
3.6.0-rc2 100 8/7/2018
3.6.0-rc1 109 8/5/2018
3.6.0-pre9 110 8/5/2018
3.6.0-pre8 110 8/5/2018
3.6.0-pre6 111 8/4/2018
3.6.0-pre3 107 8/3/2018
3.6.0-pre1 141 8/3/2018
3.5.14 122 8/2/2018
3.5.13 110 8/2/2018
3.5.12 109 8/2/2018
3.5.11 108 8/2/2018
3.5.10 112 8/1/2018
3.5.9 109 8/1/2018
3.5.8 113 7/31/2018
3.5.5 114 7/31/2018
3.5.3 128 7/25/2018
3.5.2 105 7/25/2018
3.5.1 110 7/25/2018
3.5.0 108 7/24/2018
3.5.0-pre2 105 7/23/2018
3.5.0-pre1 103 7/21/2018
3.4.8 138 7/19/2018
3.4.6 119 7/19/2018
3.4.3 125 7/19/2018
3.4.2 130 7/18/2018
3.4.0 129 7/18/2018
3.3.18 137 7/13/2018
3.3.16 115 7/12/2018
3.3.12 134 7/12/2018
3.3.11 156 7/5/2018
3.3.10 139 7/4/2018
3.3.8 144 7/1/2018
3.3.6 161 6/26/2018
3.3.4 303 6/26/2018
3.3.3 134 6/25/2018
3.3.1 152 6/13/2018
3.2.0 157 6/11/2018
3.1.0 131 6/9/2018
3.0.1 136 6/4/2018
3.0.0 141 6/2/2018
3.0.0-rc93 115 6/1/2018
3.0.0-rc92 136 5/31/2018
3.0.0-rc91 101 5/30/2018
3.0.0-rc8 113 5/29/2018
3.0.0-rc6 125 5/28/2018
3.0.0-rc5 111 5/27/2018
3.0.0-rc4 116 5/18/2018
3.0.0-rc3 120 5/16/2018
3.0.0-pre8 132 5/15/2018
3.0.0-pre4 135 5/12/2018
3.0.0-pre3 128 5/8/2018
3.0.0-pre2 128 5/7/2018
3.0.0-pre1 131 5/6/2018
2.3.2 528 3/25/2018
2.3.0 283 3/24/2018
2.2.8 177 3/8/2018
2.2.6 168 3/6/2018
2.2.2 220 2/5/2018
2.2.1 267 12/27/2017
2.2.0.2 193 12/27/2017
2.2.0.1 211 11/8/2017
2.2.0 194 11/7/2017
2.2.0-preview 167 11/3/2017
2.1.0-preview2 140 11/3/2017
2.0.18.8 148 10/24/2017
2.0.18.6 181 10/13/2017
2.0.18.5 151 10/10/2017
2.0.18.2 149 10/8/2017
2.0.18 174 9/28/2017
2.0.16 182 9/19/2017
2.0.15 176 9/19/2017
2.0.13 176 9/18/2017
2.0.12 178 9/18/2017
2.0.8 148 9/14/2017
2.0.6 148 9/12/2017
2.0.5 185 9/1/2017
2.0.4 151 8/30/2017
2.0.3 192 8/21/2017
2.0.0 165 8/16/2017
2.0.0-preview3-final 153 8/16/2017
2.0.0-preview2-final 187 8/16/2017
1.8.8.2 160 8/16/2017
1.8.8.1 165 8/15/2017
1.8.6.1 200 8/14/2017
1.8.6 196 8/11/2017
1.8.5 160 8/10/2017
1.8.3 158 8/10/2017
1.8.2 159 8/10/2017
1.8.0 166 8/10/2017
1.7.8 156 8/9/2017
1.6.7 204 8/8/2017
1.6.6 259 7/24/2017
1.6.2 258 7/19/2017
1.5.9 233 7/11/2017
1.5.8.1 254 5/27/2017
1.5.8 210 5/25/2017
1.5.5 210 5/23/2017
1.5.3 205 5/22/2017
1.5.2 208 5/22/2017
1.5.0 208 5/20/2017
1.4.9 228 4/25/2017
1.4.8 216 4/25/2017
1.4.4 220 4/21/2017
1.4.3 205 4/20/2017
1.4.2 211 4/20/2017
1.3.1 220 4/18/2017
1.2.0 212 4/17/2017
1.1.0 216 4/13/2017
1.0.4 210 4/7/2017
1.0.2 217 4/3/2017