Cola.ColaEF 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Cola.ColaEF --version 1.0.2                
NuGet\Install-Package Cola.ColaEF -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cola.ColaEF" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cola.ColaEF --version 1.0.2                
#r "nuget: Cola.ColaEF, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Cola.ColaEF as a Cake Addin
#addin nuget:?package=Cola.ColaEF&version=1.0.2

// Install Cola.ColaEF as a Cake Tool
#tool nuget:?package=Cola.ColaEF&version=1.0.2                
Cola.EF 框架
1. 注入

注入可以通过config配置文件形式注入(推荐)、也可以通过代码直接注入

{
  "ColaOrm": {
    "TenantResolutionStrategy": "NoTenant",
    "ColaOrmConfig": [
      {
        // 多租户模式租户id传参方式      
        // NoTenant  不使用多租户   RouteValueTenant 路由形式   HttpHeaderTenant  http头形式    DomainTenant   域名形式
        // 路由形式 和 http头形式  都必须传递  tenantId:value

        // 默认值 1
        "ConfigId": "1",
        "DbType": "MySql",
        "ConnectionString": "server=xxx.xxx.xxx.xxx;Database=db;Uid=root;Pwd=pwd;AllowLoadLocalInfile=true;",
        "IsAutoCloseConnection": true,
        "EnableLogAop": true,
        "EnableErrorAop": true,
        "EnableGlobalFilter": true
      }
    ]
  }
}
// 注入 ColaSqlSugar
builder.Services.AddSingletonColaSqlSugar(config,new HttpContextAccessor(),
        tableFilter:(new List<GlobalQueryFilter>()
        {
            new GlobalQueryFilter()
            {
                ConfigId = "1",
                QueryFilter = (provider => provider.AddTableFilter<IStatus>(t => t.IsDelete == false))
            }
        }),
        aopOnLogExecutingModels:new List<AopOnLogExecutingModel>()
        {
            new AopOnLogExecutingModel()
            {
                ConfigId   = "1",
                AopOnLogExecuting = ((sql, parameters) =>
                {
                    ConsoleHelper.WriteInfo($"sql is\n{sql}");
                })
            }
        },
        aopOnErrorModels:new List<AopOnErrorModel>()
        {
            new AopOnErrorModel()
            {
                ConfigId = "1",
                AopOnError = (ConsoleHelper.WriteException)
            }
        }
    );
var dbClient = builder.Services.BuildServiceProvider().GetService<ISqlSugarRepository>();
var sqlResult = dbClient.GetAll<OdinLog>();
Console.WriteLine(sqlResult.Count);
if (sqlResult.Count > 0)
{
    Console.WriteLine(JsonConvert.SerializeObject(sqlResult[0]));
}
2. 使用

详见 ConsoleApp1Test

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 196 1/4/2024
1.0.2 128 1/4/2024