SmartSql 3.7.12

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

There is a newer version of this package available.
See the version list below for details.
Install-Package SmartSql -Version 3.7.12
dotnet add package SmartSql --version 3.7.12
<PackageReference Include="SmartSql" Version="3.7.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SmartSql --version 3.7.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 AnonymousType Cache type bug

Showing the top 2 GitHub repositories that depend on SmartSql:

Repository Stars
SkyAPM/SkyAPM-dotnet
The .NET/.NET Core instrument agent for Apache SkyWalking
Shriek-Projects/shriek-fx
【WIP】️一个基于 .NET Core 2.0 开发的简单易用的快速开发框架,遵循领域驱动设计(DDD)规范约束,并结合CQRS架构提供实现事件驱动、事件回溯、响应式等特性的基础设施。让开发者享受到正真意义的面向对象设计模式来带的美感。

Version History

Version Downloads Last updated
4.1.32 61 9/30/2019
4.1.31 34 9/29/2019
4.1.30 35 9/27/2019
4.1.29 37 9/26/2019
4.1.28 57 9/2/2019
4.1.27 46 8/30/2019
4.1.26 42 8/30/2019
4.1.25 43 8/30/2019
4.1.24 60 8/28/2019
4.1.23 86 8/20/2019
4.1.22 59 8/19/2019
4.1.21 76 8/13/2019
4.1.20 66 8/13/2019
4.1.19 68 8/13/2019
4.1.18 100 8/5/2019
4.1.17 80 8/1/2019
4.1.16 73 8/1/2019
4.1.15 72 7/30/2019
4.1.14 71 7/30/2019
4.1.12 73 7/30/2019
4.1.11 74 7/30/2019
4.1.9 75 7/29/2019
4.1.8 72 7/29/2019
4.1.7 70 7/29/2019
4.1.6 74 7/29/2019
4.1.5 71 7/27/2019
4.1.3 76 7/26/2019
4.1.2 72 7/25/2019
4.1.1 70 7/25/2019
4.1.0 74 7/24/2019
4.0.88 72 7/24/2019
4.0.86 74 7/22/2019
4.0.85 75 7/22/2019
4.0.84 75 7/22/2019
4.0.81 77 7/19/2019
4.0.80 72 7/19/2019
4.0.78 73 7/19/2019
4.0.76 83 7/17/2019
4.0.75 105 7/10/2019
4.0.73 88 7/10/2019
4.0.72 113 7/5/2019
4.0.71 160 6/25/2019
4.0.70 92 6/25/2019
4.0.69 90 6/25/2019
4.0.68 111 6/20/2019
4.0.66 108 6/18/2019
4.0.65 104 6/17/2019
4.0.63 120 6/12/2019
4.0.62 91 6/12/2019
4.0.60 131 6/11/2019
4.0.59 95 6/11/2019
4.0.58 194 6/3/2019
4.0.56 149 5/31/2019
4.0.55 129 5/30/2019
4.0.53 108 5/30/2019
4.0.52 105 5/30/2019
4.0.51 107 5/30/2019
4.0.50 116 5/29/2019
4.0.49 102 5/29/2019
4.0.48 130 5/24/2019
4.0.46 209 5/15/2019
4.0.45 155 5/10/2019
4.0.44 161 5/7/2019
4.0.43 110 5/7/2019
4.0.42 243 4/28/2019
4.0.41 114 4/28/2019
4.0.40 161 4/26/2019
4.0.38 144 4/26/2019
4.0.36 140 4/25/2019
4.0.35 135 4/25/2019
4.0.34 206 4/23/2019
4.0.33 175 4/19/2019
4.0.32 160 4/19/2019
4.0.30 119 4/19/2019
4.0.29 156 4/18/2019
4.0.28 132 4/18/2019
4.0.26 137 4/18/2019
4.0.25 120 4/17/2019
4.0.21 134 4/17/2019
4.0.20 137 4/16/2019
4.0.19 158 4/15/2019
4.0.18 136 4/15/2019
4.0.16 153 4/11/2019
4.0.15 125 4/11/2019
4.0.14 149 4/9/2019
4.0.13 128 4/9/2019
4.0.12 197 4/4/2019
4.0.11 117 4/4/2019
4.0.10 161 4/3/2019
4.0.9 126 4/3/2019
4.0.8 133 4/3/2019
4.0.7 122 4/3/2019
4.0.6 121 4/3/2019
4.0.5 126 4/2/2019
4.0.4 121 4/2/2019
4.0.3 503 4/2/2019
4.0.2 129 4/1/2019
4.0.1 131 4/1/2019
4.0.0 210 4/1/2019
4.0.0-rc999 90 3/31/2019
4.0.0-rc998 86 3/29/2019
4.0.0-rc997 100 3/29/2019
4.0.0-rc996 87 3/29/2019
4.0.0-rc995 93 3/28/2019
4.0.0-rc994 89 3/28/2019
4.0.0-rc993 85 3/28/2019
4.0.0-rc991 97 3/27/2019
4.0.0-rc990 102 3/27/2019
4.0.0-rc99 92 3/27/2019
4.0.0-rc98 94 3/26/2019
4.0.0-rc97 91 3/26/2019
4.0.0-rc96 84 3/26/2019
4.0.0-rc95 96 3/25/2019
4.0.0-rc93 85 3/25/2019
4.0.0-rc92 93 3/25/2019
4.0.0-rc91 95 3/22/2019
4.0.0-rc9 104 3/22/2019
4.0.0-rc8 89 3/21/2019
4.0.0-rc6 93 3/21/2019
4.0.0-rc5 94 3/20/2019
4.0.0-rc3 141 3/18/2019
4.0.0-rc2 94 3/18/2019
4.0.0-rc10 91 3/22/2019
4.0.0-rc1 123 3/17/2019
4.0.0-beta5 84 3/16/2019
4.0.0-beta4 93 3/11/2019
4.0.0-beta3 112 3/9/2019
4.0.0-beta2 102 3/8/2019
4.0.0-beta1 99 3/7/2019
3.8.15 386 4/26/2019
3.8.13 125 4/9/2019
3.8.12 567 12/17/2018
3.8.9 125 3/26/2019
3.8.8 198 12/5/2018
3.8.6 226 11/29/2018
3.8.5 161 11/29/2018
3.8.4 955 11/9/2018
3.8.2 419 10/30/2018
3.8.0 179 10/29/2018
3.7.16 971 10/26/2018
3.7.15 442 10/24/2018
3.7.15-rc4 138 10/24/2018
3.7.15-rc2 128 10/23/2018
3.7.13 200 10/22/2018
3.7.12 176 10/22/2018
3.7.11 201 10/21/2018
3.7.10 267 10/11/2018
3.7.9 194 10/10/2018
3.7.8 302 9/30/2018
3.7.6 206 9/28/2018
3.7.5 190 9/26/2018
3.7.3 225 9/26/2018
3.7.2 179 9/25/2018
3.7.1 196 9/25/2018
3.7.0 225 9/18/2018
3.7.0-pre6 186 9/17/2018
3.6.9 199 9/16/2018
3.6.8.2 194 9/12/2018
3.6.8.1 388 9/9/2018
3.6.7 353 9/7/2018
3.6.5 247 9/1/2018
3.6.4 205 8/28/2018
3.6.2 232 8/23/2018
3.6.1 435 8/13/2018
3.6.0 294 8/8/2018
3.6.0-rc2 170 8/7/2018
3.6.0-rc1 174 8/5/2018
3.6.0-pre9 212 8/5/2018
3.6.0-pre8 215 8/5/2018
3.6.0-pre6 210 8/4/2018
3.6.0-pre3 204 8/3/2018
3.6.0-pre1 264 8/3/2018
3.5.14 221 8/2/2018
3.5.13 217 8/2/2018
3.5.12 207 8/2/2018
3.5.11 207 8/2/2018
3.5.10 202 8/1/2018
3.5.9 197 8/1/2018
3.5.8 212 7/31/2018
3.5.5 213 7/31/2018
3.5.3 230 7/25/2018
3.5.2 208 7/25/2018
3.5.1 208 7/25/2018
3.5.0 208 7/24/2018
3.5.0-pre2 207 7/23/2018
3.5.0-pre1 207 7/21/2018
3.4.8 250 7/19/2018
3.4.6 222 7/19/2018
3.4.3 230 7/19/2018
3.4.2 244 7/18/2018
3.4.0 246 7/18/2018
3.3.18 240 7/13/2018
3.3.16 215 7/12/2018
3.3.12 257 7/12/2018
3.3.11 276 7/5/2018
3.3.10 256 7/4/2018
3.3.8 265 7/1/2018
3.3.6 280 6/26/2018
3.3.4 479 6/26/2018
3.3.3 268 6/25/2018
3.3.1 286 6/13/2018
3.2.0 307 6/11/2018
3.1.0 269 6/9/2018
3.0.1 272 6/4/2018
3.0.0 265 6/2/2018
3.0.0-rc93 193 6/1/2018
3.0.0-rc92 222 5/31/2018
3.0.0-rc91 179 5/30/2018
3.0.0-rc8 196 5/29/2018
3.0.0-rc6 212 5/28/2018
3.0.0-rc5 201 5/27/2018
3.0.0-rc4 207 5/18/2018
3.0.0-rc3 199 5/16/2018
3.0.0-pre8 258 5/15/2018
3.0.0-pre4 276 5/12/2018
3.0.0-pre3 269 5/8/2018
3.0.0-pre2 234 5/7/2018
3.0.0-pre1 260 5/6/2018
2.3.2 762 3/25/2018
2.3.0 423 3/24/2018
2.2.8 333 3/8/2018
2.2.6 289 3/6/2018
2.2.2 417 2/5/2018
2.2.1 392 12/27/2017
2.2.0.2 336 12/27/2017
2.2.0.1 344 11/8/2017
2.2.0 323 11/7/2017
2.2.0-preview 294 11/3/2017
2.1.0-preview2 259 11/3/2017
2.0.18.8 270 10/24/2017
2.0.18.6 324 10/13/2017
2.0.18.5 273 10/10/2017
2.0.18.2 266 10/8/2017
2.0.18 302 9/28/2017
2.0.16 321 9/19/2017
2.0.15 320 9/19/2017
2.0.13 340 9/18/2017
2.0.12 316 9/18/2017
2.0.8 267 9/14/2017
2.0.6 264 9/12/2017
2.0.5 302 9/1/2017
2.0.4 284 8/30/2017
2.0.3 346 8/21/2017
2.0.0 297 8/16/2017
2.0.0-preview3-final 273 8/16/2017
2.0.0-preview2-final 328 8/16/2017
1.8.8.2 286 8/16/2017
1.8.8.1 297 8/15/2017
1.8.6.1 334 8/14/2017
1.8.6 332 8/11/2017
1.8.5 290 8/10/2017
1.8.3 280 8/10/2017
1.8.2 289 8/10/2017
1.8.0 298 8/10/2017
1.7.8 282 8/9/2017
1.6.7 344 8/8/2017
1.6.6 410 7/24/2017
1.6.2 421 7/19/2017
1.5.9 398 7/11/2017
1.5.8.1 482 5/27/2017
1.5.8 357 5/25/2017
1.5.5 349 5/23/2017
1.5.3 353 5/22/2017
1.5.2 362 5/22/2017
1.5.0 358 5/20/2017
1.4.9 384 4/25/2017
1.4.8 376 4/25/2017
1.4.4 366 4/21/2017
1.4.3 372 4/20/2017
1.4.2 377 4/20/2017
1.3.1 373 4/18/2017
1.2.0 356 4/17/2017
1.1.0 360 4/13/2017
1.0.4 362 4/7/2017
1.0.2 376 4/3/2017
Show less