SmartSql 3.5.10

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.5.10
dotnet add package SmartSql --version 3.5.10
<PackageReference Include="SmartSql" Version="3.5.10" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SmartSql --version 3.5.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. optimized RequestContext.StatementKey
     2. optimized RequestContext.Request is DbParameterCollection

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 44 9/30/2019
4.1.31 33 9/29/2019
4.1.30 34 9/27/2019
4.1.29 36 9/26/2019
4.1.28 56 9/2/2019
4.1.27 44 8/30/2019
4.1.26 40 8/30/2019
4.1.25 42 8/30/2019
4.1.24 60 8/28/2019
4.1.23 78 8/20/2019
4.1.22 56 8/19/2019
4.1.21 74 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 103 7/10/2019
4.0.73 85 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 103 6/17/2019
4.0.63 119 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 191 6/3/2019
4.0.56 149 5/31/2019
4.0.55 129 5/30/2019
4.0.53 105 5/30/2019
4.0.52 102 5/30/2019
4.0.51 105 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 207 5/15/2019
4.0.45 154 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 111 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 132 4/25/2019
4.0.34 203 4/23/2019
4.0.33 175 4/19/2019
4.0.32 160 4/19/2019
4.0.30 116 4/19/2019
4.0.29 156 4/18/2019
4.0.28 129 4/18/2019
4.0.26 134 4/18/2019
4.0.25 117 4/17/2019
4.0.21 134 4/17/2019
4.0.20 134 4/16/2019
4.0.19 158 4/15/2019
4.0.18 133 4/15/2019
4.0.16 150 4/11/2019
4.0.15 122 4/11/2019
4.0.14 146 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 500 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 122 4/9/2019
3.8.12 564 12/17/2018
3.8.9 125 3/26/2019
3.8.8 194 12/5/2018
3.8.6 226 11/29/2018
3.8.5 156 11/29/2018
3.8.4 955 11/9/2018
3.8.2 414 10/30/2018
3.8.0 174 10/29/2018
3.7.16 971 10/26/2018
3.7.15 437 10/24/2018
3.7.15-rc4 138 10/24/2018
3.7.15-rc2 128 10/23/2018
3.7.13 195 10/22/2018
3.7.12 171 10/22/2018
3.7.11 199 10/21/2018
3.7.10 265 10/11/2018
3.7.9 189 10/10/2018
3.7.8 297 9/30/2018
3.7.6 204 9/28/2018
3.7.5 185 9/26/2018
3.7.3 220 9/26/2018
3.7.2 174 9/25/2018
3.7.1 191 9/25/2018
3.7.0 220 9/18/2018
3.7.0-pre6 184 9/17/2018
3.6.9 197 9/16/2018
3.6.8.2 189 9/12/2018
3.6.8.1 383 9/9/2018
3.6.7 348 9/7/2018
3.6.5 247 9/1/2018
3.6.4 200 8/28/2018
3.6.2 230 8/23/2018
3.6.1 430 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 208 8/4/2018
3.6.0-pre3 204 8/3/2018
3.6.0-pre1 264 8/3/2018
3.5.14 216 8/2/2018
3.5.13 215 8/2/2018
3.5.12 207 8/2/2018
3.5.11 205 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 210 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 202 7/23/2018
3.5.0-pre1 207 7/21/2018
3.4.8 248 7/19/2018
3.4.6 222 7/19/2018
3.4.3 230 7/19/2018
3.4.2 242 7/18/2018
3.4.0 244 7/18/2018
3.3.18 240 7/13/2018
3.3.16 213 7/12/2018
3.3.12 255 7/12/2018
3.3.11 274 7/5/2018
3.3.10 251 7/4/2018
3.3.8 260 7/1/2018
3.3.6 280 6/26/2018
3.3.4 474 6/26/2018
3.3.3 266 6/25/2018
3.3.1 284 6/13/2018
3.2.0 307 6/11/2018
3.1.0 264 6/9/2018
3.0.1 267 6/4/2018
3.0.0 260 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 253 5/15/2018
3.0.0-pre4 271 5/12/2018
3.0.0-pre3 264 5/8/2018
3.0.0-pre2 229 5/7/2018
3.0.0-pre1 255 5/6/2018
2.3.2 758 3/25/2018
2.3.0 423 3/24/2018
2.2.8 328 3/8/2018
2.2.6 284 3/6/2018
2.2.2 412 2/5/2018
2.2.1 389 12/27/2017
2.2.0.2 331 12/27/2017
2.2.0.1 339 11/8/2017
2.2.0 318 11/7/2017
2.2.0-preview 289 11/3/2017
2.1.0-preview2 254 11/3/2017
2.0.18.8 265 10/24/2017
2.0.18.6 319 10/13/2017
2.0.18.5 268 10/10/2017
2.0.18.2 261 10/8/2017
2.0.18 298 9/28/2017
2.0.16 316 9/19/2017
2.0.15 315 9/19/2017
2.0.13 340 9/18/2017
2.0.12 311 9/18/2017
2.0.8 267 9/14/2017
2.0.6 259 9/12/2017
2.0.5 297 9/1/2017
2.0.4 279 8/30/2017
2.0.3 341 8/21/2017
2.0.0 292 8/16/2017
2.0.0-preview3-final 268 8/16/2017
2.0.0-preview2-final 323 8/16/2017
1.8.8.2 281 8/16/2017
1.8.8.1 292 8/15/2017
1.8.6.1 329 8/14/2017
1.8.6 327 8/11/2017
1.8.5 285 8/10/2017
1.8.3 275 8/10/2017
1.8.2 284 8/10/2017
1.8.0 293 8/10/2017
1.7.8 277 8/9/2017
1.6.7 339 8/8/2017
1.6.6 405 7/24/2017
1.6.2 421 7/19/2017
1.5.9 393 7/11/2017
1.5.8.1 477 5/27/2017
1.5.8 353 5/25/2017
1.5.5 344 5/23/2017
1.5.3 349 5/22/2017
1.5.2 357 5/22/2017
1.5.0 353 5/20/2017
1.4.9 379 4/25/2017
1.4.8 371 4/25/2017
1.4.4 361 4/21/2017
1.4.3 367 4/20/2017
1.4.2 372 4/20/2017
1.3.1 368 4/18/2017
1.2.0 351 4/17/2017
1.1.0 355 4/13/2017
1.0.4 358 4/7/2017
1.0.2 371 4/3/2017
Show less