From 5396b085c8a922fc352616905268f3614b1469c9 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 5 Jul 2023 22:16:45 +0800 Subject: [PATCH] Synchronization code --- Src/Asp.Net/SqlSugar/SugarUnitOfWork.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/SugarUnitOfWork.cs b/Src/Asp.Net/SqlSugar/SugarUnitOfWork.cs index 8e6478702..496a77d01 100644 --- a/Src/Asp.Net/SqlSugar/SugarUnitOfWork.cs +++ b/Src/Asp.Net/SqlSugar/SugarUnitOfWork.cs @@ -83,8 +83,8 @@ namespace SqlSugar public RepositoryType GetMyRepository() where RepositoryType:new() { var result = (ISugarRepository)new RepositoryType(); - var type = typeof(RepositoryType).GetGenericArguments()[0]; - TenantAttribute tenantAttribute = type.GetCustomAttribute(); + var type = typeof(RepositoryType).GetGenericArguments().FirstOrDefault(); + TenantAttribute tenantAttribute = type?.GetCustomAttribute(); if (tenantAttribute == null) { result.Context = this.Db;