SmartSql.DyRepository 3.6.1

There is a newer version of this package available.
See the version list below for details.
Install-Package SmartSql.DyRepository -Version 3.6.1
dotnet add package SmartSql.DyRepository --version 3.6.1
<PackageReference Include="SmartSql.DyRepository" Version="3.6.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SmartSql.DyRepository --version 3.6.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SmartSql.DyRepository, 3.6.1"
#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.6.1

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

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,548 11/17/2020
4.1.56 1,449 7/14/2020
4.1.55 1,599 6/18/2020
4.1.54 886 6/12/2020
4.1.53 1,634 4/8/2020
4.1.52 970 3/27/2020
4.1.51 1,029 3/21/2020
4.1.50 872 3/9/2020
4.1.48 810 3/5/2020
4.1.46 978 12/18/2019
4.1.45 801 12/18/2019
4.1.44 1,096 12/5/2019
4.1.43 878 11/20/2019
4.1.42 1,035 11/18/2019
4.1.40 750 11/12/2019
4.1.39 832 11/6/2019
4.1.38 851 10/29/2019
4.1.37 786 10/29/2019
4.1.36 812 10/29/2019
4.1.35 828 10/29/2019
4.1.34 770 10/28/2019
4.1.33 800 10/28/2019
4.1.32 6,854 9/30/2019
4.1.31 759 9/29/2019
4.1.30 758 9/27/2019
4.1.29 786 9/26/2019
4.1.28 906 9/2/2019
4.1.27 816 8/30/2019
4.1.26 836 8/30/2019
4.1.25 832 8/30/2019
4.1.24 921 8/28/2019
4.1.23 2,115 8/20/2019
4.1.22 791 8/19/2019
4.1.21 850 8/13/2019
4.1.20 816 8/13/2019
4.1.19 860 8/13/2019
4.1.18 1,000 8/5/2019
4.1.17 976 8/1/2019
4.1.16 867 8/1/2019
4.1.15 847 7/30/2019
4.1.14 861 7/30/2019
4.1.12 869 7/30/2019
4.1.11 893 7/30/2019
4.1.9 821 7/29/2019
4.1.8 859 7/29/2019
4.1.7 842 7/29/2019
4.1.6 906 7/29/2019
4.1.5 847 7/27/2019
4.1.3 831 7/26/2019
4.1.2 850 7/25/2019
4.1.1 818 7/25/2019
4.1.0 845 7/24/2019
4.0.88 812 7/24/2019
4.0.86 796 7/22/2019
4.0.85 855 7/22/2019
4.0.84 828 7/22/2019
4.0.81 867 7/19/2019
4.0.80 866 7/19/2019
4.0.78 815 7/19/2019
4.0.76 912 7/17/2019
4.0.75 906 7/10/2019
4.0.73 894 7/10/2019
4.0.72 923 7/5/2019
4.0.71 931 6/25/2019
4.0.70 840 6/25/2019
4.0.69 847 6/25/2019
4.0.68 833 6/20/2019
4.0.66 858 6/18/2019
4.0.65 917 6/17/2019
4.0.63 1,674 6/12/2019
4.0.62 827 6/12/2019
4.0.60 900 6/11/2019
4.0.59 824 6/11/2019
4.0.58 933 6/3/2019
4.0.56 862 5/31/2019
4.0.55 827 5/30/2019
4.0.53 847 5/30/2019
4.0.52 831 5/30/2019
4.0.51 868 5/30/2019
4.0.50 854 5/29/2019
4.0.49 872 5/29/2019
4.0.48 851 5/24/2019
4.0.46 893 5/15/2019
4.0.45 810 5/10/2019
4.0.44 697 5/7/2019
4.0.43 646 5/7/2019
4.0.42 866 4/28/2019
4.0.41 654 4/28/2019
4.0.40 683 4/26/2019
4.0.38 698 4/26/2019
4.0.36 680 4/25/2019
4.0.35 673 4/25/2019
4.0.34 755 4/23/2019
4.0.33 696 4/19/2019
4.0.32 737 4/19/2019
4.0.30 689 4/19/2019
4.0.29 672 4/18/2019
4.0.28 649 4/18/2019
4.0.26 656 4/18/2019
4.0.25 662 4/17/2019
4.0.21 666 4/17/2019
4.0.20 667 4/16/2019
4.0.19 683 4/15/2019
4.0.18 649 4/15/2019
4.0.16 692 4/11/2019
4.0.15 640 4/11/2019
4.0.14 675 4/9/2019
4.0.13 571 4/9/2019
4.0.12 625 4/4/2019
4.0.11 566 4/4/2019
4.0.10 490 4/3/2019
4.0.8 449 4/3/2019
4.0.7 444 4/3/2019
4.0.6 417 4/3/2019
4.0.5 489 4/2/2019
4.0.4 486 4/2/2019
4.0.3 558 4/2/2019
4.0.2 487 4/1/2019
4.0.0 480 4/1/2019
4.0.0-rc999 389 3/31/2019
4.0.0-rc998 346 3/29/2019
4.0.0-rc997 327 3/29/2019
4.0.0-rc996 313 3/29/2019
4.0.0-rc995 334 3/28/2019
4.0.0-rc994 347 3/28/2019
4.0.0-rc993 362 3/28/2019
4.0.0-rc991 349 3/27/2019
4.0.0-rc990 342 3/27/2019
4.0.0-rc99 353 3/27/2019
4.0.0-rc98 359 3/26/2019
4.0.0-rc97 343 3/26/2019
4.0.0-rc96 333 3/26/2019
4.0.0-rc95 362 3/25/2019
4.0.0-rc93 341 3/25/2019
4.0.0-rc92 346 3/25/2019
4.0.0-rc91 346 3/22/2019
4.0.0-rc9 343 3/22/2019
4.0.0-rc8 343 3/21/2019
4.0.0-rc6 353 3/21/2019
4.0.0-rc5 341 3/20/2019
4.0.0-rc3 315 3/19/2019
4.0.0-rc10 342 3/22/2019
4.0.0-rc1 372 3/17/2019
4.0.0-beta5 348 3/16/2019
4.0.0-beta4 347 3/11/2019
4.0.0-beta3 356 3/9/2019
4.0.0-beta2 352 3/8/2019
4.0.0-beta1 351 3/7/2019
3.8.12 926 12/17/2018
3.8.8 506 12/11/2018
3.7.16 2,962 10/26/2018
3.7.15 613 10/24/2018
3.7.13 639 10/22/2018
3.7.10 784 10/11/2018
3.7.9 507 10/11/2018
3.6.1 1,880 8/10/2018
3.6.0 647 8/8/2018
3.6.0-rc2 493 8/7/2018
3.6.0-rc1 512 8/5/2018
3.6.0-pre8 537 8/5/2018
3.6.0-pre6 530 8/4/2018
3.5.9 594 8/1/2018
3.5.8 638 7/31/2018
3.5.6 542 7/31/2018
3.5.5 628 7/26/2018
3.5.4 646 7/26/2018
3.5.3 603 7/25/2018
3.5.0 686 7/24/2018
3.5.0-pre2 556 7/23/2018
3.4.9 649 7/21/2018
3.4.8 657 7/19/2018
3.4.6 679 7/19/2018
3.3.12 850 7/17/2018
3.3.10 609 7/16/2018
3.3.8 742 6/29/2018
3.3.6 700 6/26/2018
3.3.4 838 6/26/2018
3.3.2 920 6/21/2018
3.3.0 677 6/11/2018
3.2.0 741 6/11/2018
3.1.0 723 6/9/2018
3.0.0 817 6/2/2018
3.0.0-rc92 602 5/31/2018
3.0.0-rc91 648 5/30/2018
3.0.0-rc6 668 5/28/2018
3.0.0-rc11 739 5/30/2018
3.0.0-pre9 719 5/15/2018
3.0.0-pre2 641 5/6/2018
3.0.0-pre1 613 5/6/2018
1.0.1 735 4/24/2018
1.0.0 878 4/21/2018
1.0.0-pre 624 4/19/2018

1. add SqlIdNamingConvert