SmartSql 3.7.10

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

Install-Package SmartSql -Version 3.7.10
dotnet add package SmartSql --version 3.7.10
paket add SmartSql --version 3.7.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. add SmartSqlExtensions.SessionWrap

Version History

Version Downloads Last updated
3.7.10 56 10/11/2018
3.7.9 45 10/10/2018
3.7.8 71 9/30/2018
3.7.6 48 9/28/2018
3.7.5 48 9/26/2018
3.7.3 56 9/26/2018
3.7.2 41 9/25/2018
3.7.1 41 9/25/2018
3.7.0 62 9/18/2018
3.7.0-pre6 38 9/17/2018
3.6.9 47 9/16/2018
3.6.8.2 47 9/12/2018
3.6.8.1 81 9/9/2018
3.6.7 75 9/7/2018
3.6.5 87 9/1/2018
3.6.4 65 8/28/2018
3.6.2 84 8/23/2018
3.6.1 86 8/13/2018
3.6.0 116 8/8/2018
3.6.0-rc2 49 8/7/2018
3.6.0-rc1 59 8/5/2018
3.6.0-pre9 52 8/5/2018
3.6.0-pre8 52 8/5/2018
3.6.0-pre6 53 8/4/2018
3.6.0-pre3 51 8/3/2018
3.6.0-pre1 79 8/3/2018
3.5.14 64 8/2/2018
3.5.13 54 8/2/2018
3.5.12 53 8/2/2018
3.5.11 52 8/2/2018
3.5.10 56 8/1/2018
3.5.9 52 8/1/2018
3.5.8 55 7/31/2018
3.5.5 58 7/31/2018
3.5.3 69 7/25/2018
3.5.2 49 7/25/2018
3.5.1 54 7/25/2018
3.5.0 53 7/24/2018
3.5.0-pre2 50 7/23/2018
3.5.0-pre1 47 7/21/2018
3.4.8 79 7/19/2018
3.4.6 63 7/19/2018
3.4.3 66 7/19/2018
3.4.2 70 7/18/2018
3.4.0 69 7/18/2018
3.3.18 78 7/13/2018
3.3.16 59 7/12/2018
3.3.12 73 7/12/2018
3.3.11 94 7/5/2018
3.3.10 80 7/4/2018
3.3.8 86 7/1/2018
3.3.6 100 6/26/2018
3.3.4 146 6/26/2018
3.3.3 76 6/25/2018
3.3.1 91 6/13/2018
3.2.0 93 6/11/2018
3.1.0 69 6/9/2018
3.0.1 77 6/4/2018
3.0.0 79 6/2/2018
3.0.0-rc93 62 6/1/2018
3.0.0-rc92 67 5/31/2018
3.0.0-rc91 52 5/30/2018
3.0.0-rc8 62 5/29/2018
3.0.0-rc6 75 5/28/2018
3.0.0-rc5 60 5/27/2018
3.0.0-rc4 65 5/18/2018
3.0.0-rc3 69 5/16/2018
3.0.0-pre8 71 5/15/2018
3.0.0-pre4 72 5/12/2018
3.0.0-pre3 68 5/8/2018
3.0.0-pre2 69 5/7/2018
3.0.0-pre1 71 5/6/2018
2.3.2 362 3/25/2018
2.3.0 220 3/24/2018
2.2.8 109 3/8/2018
2.2.6 108 3/6/2018
2.2.2 142 2/5/2018
2.2.1 191 12/27/2017
2.2.0.2 125 12/27/2017
2.2.0.1 147 11/8/2017
2.2.0 131 11/7/2017
2.2.0-preview 106 11/3/2017
2.1.0-preview2 85 11/3/2017
2.0.18.8 93 10/24/2017
2.0.18.6 122 10/13/2017
2.0.18.5 97 10/10/2017
2.0.18.2 95 10/8/2017
2.0.18 116 9/28/2017
2.0.16 120 9/19/2017
2.0.15 116 9/19/2017
2.0.13 115 9/18/2017
2.0.12 115 9/18/2017
2.0.8 95 9/14/2017
2.0.6 94 9/12/2017
2.0.5 127 9/1/2017
2.0.4 96 8/30/2017
2.0.3 132 8/21/2017
2.0.0 110 8/16/2017
2.0.0-preview3-final 98 8/16/2017
2.0.0-preview2-final 126 8/16/2017
1.8.8.2 105 8/16/2017
1.8.8.1 109 8/15/2017
1.8.6.1 139 8/14/2017
1.8.6 134 8/11/2017
1.8.5 106 8/10/2017
1.8.3 102 8/10/2017
1.8.2 104 8/10/2017
1.8.0 112 8/10/2017
1.7.8 102 8/9/2017
1.6.7 145 8/8/2017
1.6.6 198 7/24/2017
1.6.2 200 7/19/2017
1.5.9 163 7/11/2017
1.5.8.1 176 5/27/2017
1.5.8 150 5/25/2017
1.5.5 148 5/23/2017
1.5.3 146 5/22/2017
1.5.2 151 5/22/2017
1.5.0 148 5/20/2017
1.4.9 168 4/25/2017
1.4.8 158 4/25/2017
1.4.4 158 4/21/2017
1.4.3 147 4/20/2017
1.4.2 154 4/20/2017
1.3.1 140 4/18/2017
1.2.0 154 4/17/2017
1.1.0 151 4/13/2017
1.0.4 152 4/7/2017
1.0.2 159 4/3/2017