SmartSql.DyRepository 3.5.4

There is a newer version of this package available.
See the version list below for details.
Install-Package SmartSql.DyRepository -Version 3.5.4
dotnet add package SmartSql.DyRepository --version 3.5.4
<PackageReference Include="SmartSql.DyRepository" Version="3.5.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SmartSql.DyRepository --version 3.5.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SmartSql.DyRepository, 3.5.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install SmartSql.DyRepository as a Cake Addin
#addin nuget:?package=SmartSql.DyRepository&version=3.5.4

// Install SmartSql.DyRepository as a Cake Tool
#tool nuget:?package=SmartSql.DyRepository&version=3.5.4
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

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SmartSql.DyRepository:

Package Downloads
SmartSql.DIExtension

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

SmartSql.Test

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

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.1.57 3,580 11/17/2020
4.1.56 1,459 7/14/2020
4.1.55 1,613 6/18/2020
4.1.54 896 6/12/2020
4.1.53 1,651 4/8/2020
4.1.52 982 3/27/2020
4.1.51 1,032 3/21/2020
4.1.50 885 3/9/2020
4.1.48 822 3/5/2020
4.1.46 993 12/18/2019
4.1.45 811 12/18/2019
4.1.44 1,110 12/5/2019
4.1.43 887 11/20/2019
4.1.42 1,045 11/18/2019
4.1.40 758 11/12/2019
4.1.39 847 11/6/2019
4.1.38 864 10/29/2019
4.1.37 798 10/29/2019
4.1.36 820 10/29/2019
4.1.35 837 10/29/2019
4.1.34 788 10/28/2019
4.1.33 815 10/28/2019
4.1.32 6,913 9/30/2019
4.1.31 767 9/29/2019
4.1.30 766 9/27/2019
4.1.29 796 9/26/2019
4.1.28 917 9/2/2019
4.1.27 831 8/30/2019
4.1.26 846 8/30/2019
4.1.25 851 8/30/2019
4.1.24 926 8/28/2019
4.1.23 2,129 8/20/2019
4.1.22 808 8/19/2019
4.1.21 853 8/13/2019
4.1.20 829 8/13/2019
4.1.19 870 8/13/2019
4.1.18 1,004 8/5/2019
4.1.17 986 8/1/2019
4.1.16 877 8/1/2019
4.1.15 866 7/30/2019
4.1.14 869 7/30/2019
4.1.12 880 7/30/2019
4.1.11 907 7/30/2019
4.1.9 836 7/29/2019
4.1.8 867 7/29/2019
4.1.7 852 7/29/2019
4.1.6 911 7/29/2019
4.1.5 861 7/27/2019
4.1.3 838 7/26/2019
4.1.2 858 7/25/2019
4.1.1 838 7/25/2019
4.1.0 855 7/24/2019
4.0.88 821 7/24/2019
4.0.86 811 7/22/2019
4.0.85 860 7/22/2019
4.0.84 838 7/22/2019
4.0.81 879 7/19/2019
4.0.80 875 7/19/2019
4.0.78 825 7/19/2019
4.0.76 914 7/17/2019
4.0.75 911 7/10/2019
4.0.73 902 7/10/2019
4.0.72 939 7/5/2019
4.0.71 943 6/25/2019
4.0.70 843 6/25/2019
4.0.69 854 6/25/2019
4.0.68 846 6/20/2019
4.0.66 868 6/18/2019
4.0.65 925 6/17/2019
4.0.63 1,692 6/12/2019
4.0.62 835 6/12/2019
4.0.60 913 6/11/2019
4.0.59 841 6/11/2019
4.0.58 945 6/3/2019
4.0.56 867 5/31/2019
4.0.55 840 5/30/2019
4.0.53 866 5/30/2019
4.0.52 834 5/30/2019
4.0.51 871 5/30/2019
4.0.50 857 5/29/2019
4.0.49 878 5/29/2019
4.0.48 863 5/24/2019
4.0.46 898 5/15/2019
4.0.45 815 5/10/2019
4.0.44 707 5/7/2019
4.0.43 656 5/7/2019
4.0.42 881 4/28/2019
4.0.41 672 4/28/2019
4.0.40 695 4/26/2019
4.0.38 704 4/26/2019
4.0.36 692 4/25/2019
4.0.35 678 4/25/2019
4.0.34 761 4/23/2019
4.0.33 704 4/19/2019
4.0.32 743 4/19/2019
4.0.30 695 4/19/2019
4.0.29 678 4/18/2019
4.0.28 660 4/18/2019
4.0.26 667 4/18/2019
4.0.25 668 4/17/2019
4.0.21 675 4/17/2019
4.0.20 685 4/16/2019
4.0.19 689 4/15/2019
4.0.18 660 4/15/2019
4.0.16 704 4/11/2019
4.0.15 648 4/11/2019
4.0.14 683 4/9/2019
4.0.13 579 4/9/2019
4.0.12 632 4/4/2019
4.0.11 568 4/4/2019
4.0.10 498 4/3/2019
4.0.8 456 4/3/2019
4.0.7 449 4/3/2019
4.0.6 420 4/3/2019
4.0.5 497 4/2/2019
4.0.4 489 4/2/2019
4.0.3 566 4/2/2019
4.0.2 490 4/1/2019
4.0.0 483 4/1/2019
4.0.0-rc999 392 3/31/2019
4.0.0-rc998 349 3/29/2019
4.0.0-rc997 330 3/29/2019
4.0.0-rc996 319 3/29/2019
4.0.0-rc995 340 3/28/2019
4.0.0-rc994 353 3/28/2019
4.0.0-rc993 368 3/28/2019
4.0.0-rc991 355 3/27/2019
4.0.0-rc990 348 3/27/2019
4.0.0-rc99 360 3/27/2019
4.0.0-rc98 365 3/26/2019
4.0.0-rc97 349 3/26/2019
4.0.0-rc96 339 3/26/2019
4.0.0-rc95 365 3/25/2019
4.0.0-rc93 347 3/25/2019
4.0.0-rc92 352 3/25/2019
4.0.0-rc91 349 3/22/2019
4.0.0-rc9 347 3/22/2019
4.0.0-rc8 347 3/21/2019
4.0.0-rc6 358 3/21/2019
4.0.0-rc5 344 3/20/2019
4.0.0-rc3 321 3/19/2019
4.0.0-rc10 348 3/22/2019
4.0.0-rc1 377 3/17/2019
4.0.0-beta5 354 3/16/2019
4.0.0-beta4 353 3/11/2019
4.0.0-beta3 362 3/9/2019
4.0.0-beta2 359 3/8/2019
4.0.0-beta1 354 3/7/2019
3.8.12 929 12/17/2018
3.8.8 509 12/11/2018
3.7.16 2,967 10/26/2018
3.7.15 621 10/24/2018
3.7.13 642 10/22/2018
3.7.10 788 10/11/2018
3.7.9 509 10/11/2018
3.6.1 1,895 8/10/2018
3.6.0 652 8/8/2018
3.6.0-rc2 498 8/7/2018
3.6.0-rc1 517 8/5/2018
3.6.0-pre8 542 8/5/2018
3.6.0-pre6 535 8/4/2018
3.5.9 599 8/1/2018
3.5.8 643 7/31/2018
3.5.6 547 7/31/2018
3.5.5 633 7/26/2018
3.5.4 656 7/26/2018
3.5.3 608 7/25/2018
3.5.0 693 7/24/2018
3.5.0-pre2 561 7/23/2018
3.4.9 654 7/21/2018
3.4.8 669 7/19/2018
3.4.6 684 7/19/2018
3.3.12 867 7/17/2018
3.3.10 621 7/16/2018
3.3.8 748 6/29/2018
3.3.6 707 6/26/2018
3.3.4 853 6/26/2018
3.3.2 942 6/21/2018
3.3.0 682 6/11/2018
3.2.0 748 6/11/2018
3.1.0 730 6/9/2018
3.0.0 822 6/2/2018
3.0.0-rc92 609 5/31/2018
3.0.0-rc91 655 5/30/2018
3.0.0-rc6 675 5/28/2018
3.0.0-rc11 744 5/30/2018
3.0.0-pre9 725 5/15/2018
3.0.0-pre2 650 5/6/2018
3.0.0-pre1 622 5/6/2018
1.0.1 744 4/24/2018
1.0.0 898 4/21/2018
1.0.0-pre 633 4/19/2018

1. fix Generic nested return value bug