mccj - SqlSugarUtility 1.0.18

A powerful extension toolkit for SqlSugar ORM. Provides a flexible client factory with easy configuration (singleton/scope), integrates Yitter SnowFlake ID generator, and offers rich extension methods for SimpleClient and ISugarQueryable. Simplifies common data access patterns like paging, array conversion, and attribute-based entity mapping.

PM> Install-Package SqlSugarUtility -Version 1.0.18 -Source https://www.myget.org/F/mccj/api/v3/index.json

Copy to clipboard

> nuget.exe install SqlSugarUtility -Version 1.0.18 -Source https://www.myget.org/F/mccj/api/v3/index.json

Copy to clipboard

> dotnet add package SqlSugarUtility --version 1.0.18 --source https://www.myget.org/F/mccj/api/v3/index.json

Copy to clipboard
<PackageReference Include="SqlSugarUtility" Version="1.0.18" />
Copy to clipboard
source https://www.myget.org/F/mccj/api/v3/index.json

nuget SqlSugarUtility  ~> 1.0.18
Copy to clipboard

> choco install SqlSugarUtility --version 1.0.18 --source https://www.myget.org/F/mccj/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "mccj" -SourceLocation "https://www.myget.org/F/mccj/api/v2"
Install-Module -Name "SqlSugarUtility" -RequiredVersion "1.0.18" -Repository "mccj" 
Copy to clipboard

Browse the sources in this package using Visual Studio or WinDbg by configuring the following symbol server URL: https://www.myget.org/F/mccj/api/v2/symbolpackage/


SqlSugarUtility

Build status MyGet NuGet MIT License

using SqlSugar;

public static class SqlSugarHelper
{
    private static ISqlSugarClient? _client = null;
    public static ISqlSugarClient Db
    {
        get
        {
            if (_client == null)
            {

                var dbType = DbType.SqlServer;
                //var connectionString = "Data Source=192.168.x.x;Initial Catalog=xxx;User ID=sa;PWD=xxx";
                if (string.IsNullOrWhiteSpace(connectionString)) throw new Exception("连接字符串不能空");

                _client = SqlSugarUtility.GetSingletonSqlSugarClient<IgnoreAttribute>(dbType, connectionString, false, db =>
                {
                    //(A)全局生效配置点,一般AOP和程序启动的配置扔这里面 ,所有上下文生效
                    //调试SQL事件,可以删掉
                    db.Aop.OnLogExecuting = (sql, pars) =>
                    {
#if DEBUG
                        //Console.WriteLine(sql);//输出sql,查看执行sql 性能无影响

                        //5.0.8.2 获取无参数化 SQL  对性能有影响,特别大的SQL参数多的,调试使用
                        var sql2 = UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, sql, pars);
                        Console.WriteLine(sql2);//输出sql,查看执行sql 性能无影响
                        System.Diagnostics.Debug.WriteLine(sql2);
#endif
                    };
                    db.Aop.OnError = (ex) =>
                    {
                        Console.WriteLine(ex.Message);//输出sql,查看执行sql 性能无影响
                        System.Diagnostics.Debug.Fail(ex.Message);
                    };
                    db.Aop.OnDiffLogEvent = (diff) =>
                    {

                    };
                });

            }
            return _client;
        }
    }
}
public class IgnoreAttribute : Attribute { }

v1.0.0

  • 🚀 SqlSugar Client Factory: Simplified creation of SqlSugarScope and SqlSugarClient with built-in attribute mapping (Description, DefaultValue, Key, etc.).
  • ❄️ SnowFlake ID Integration: Customizable SnowFlake ID generator (Yitter) configured by default.
  • 🔧 Convenience Extensions: Added paging, counting, and array conversion methods for SimpleClient and ISugarQueryable (e.g., ToPageList, ForEachByPage, GetArray).
  • 🧩 Attribute Support: Automatic recognition of common .NET attributes for database schema definition.
  • .NETFramework 4.8
    • SqlSugar (>= 5.1.4.207)
    • System.ComponentModel.Annotations (>= 5.0.0)
    • Yitter.IdGenerator.Net45 (>= 1.0.0)
  • .NETStandard 2.1
    • SqlSugarCore (>= 5.1.4.214)
    • System.ComponentModel.Annotations (>= 5.0.0)
    • Yitter.IdGenerator (>= 1.0.15)
  • .NETFramework 4.8: 4.8.0.0
  • .NETStandard 2.1: 2.1.0.0

Owners

mccj

Authors

mccj

Project URL

https://github.com/mccj/SqlSugarUtility

License

Unknown

Tags

sqlsugar orm extension utility pagination snowflake id-generator data-access .net database

Info

82 total downloads
0 downloads for version 1.0.18
Download (22.82 KB)
Download symbols (13.99 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.0.19 22.81 KB Tue, 12 May 2026 07:08:19 GMT 0
1.0.18 22.82 KB Tue, 12 May 2026 07:03:32 GMT 0
1.0.14 22.85 KB Tue, 24 Feb 2026 09:47:35 GMT 2
1.0.13 17.82 KB Fri, 15 Aug 2025 06:07:06 GMT 11
1.0.12 17.87 KB Fri, 15 Aug 2025 02:53:22 GMT 6
1.0.11 17.89 KB Thu, 08 May 2025 02:26:14 GMT 11
1.0.10 17.88 KB Wed, 30 Apr 2025 05:51:59 GMT 12
1.0.8 16.98 KB Tue, 21 Jan 2025 05:50:10 GMT 23
1.0.7 16.35 KB Tue, 04 Jun 2024 08:32:00 GMT 17