From 1fbb34491956e40180cfb61859a13ddf0ea33eff Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周三, 14 5月 2025 11:09:14 +0800
Subject: [PATCH] 解决查询失败,转换对象不对的问题

---
 Weben_CMS专用代码生成器/Code/Templete/EntityFrameworkCore/EfCoreRepository模板.txt |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/EntityFrameworkCore/EfCoreRepository\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/EntityFrameworkCore/EfCoreRepository\346\250\241\346\235\277.txt"
index 39ea7e4..efb086b 100644
--- "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/EntityFrameworkCore/EfCoreRepository\346\250\241\346\235\277.txt"
+++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/EntityFrameworkCore/EfCoreRepository\346\250\241\346\235\277.txt"
@@ -174,6 +174,7 @@
     public async Task<List<$EntityName$>> GetListByFilterAsync(Expression<Func<$EntityName$, bool>> whereConditions, CancellationToken cancellationToken = default)
     {
         return await (await GetDbSetAsync())
+            .IncludeDetails()
             .WhereIf(whereConditions != null, whereConditions)
             .Where(x => !x.IsDeleted)
             .OrderByDescending(x => x.$OrderBy$)
@@ -193,10 +194,11 @@
         if (is鈥婱ultipleThrowException)
         {
             var entitys = await (await GetDbSetAsync())
-          .WhereIf(whereConditions != null, whereConditions)
-          .Where(x => !x.IsDeleted)
-          .OrderByDescending(x => x.$OrderBy$)
-          .ToListAsync(GetCancellationToken(cancellationToken));
+                .IncludeDetails()
+                .WhereIf(whereConditions != null, whereConditions)
+                .Where(x => !x.IsDeleted)
+                .OrderByDescending(x => x.$OrderBy$)
+                .ToListAsync(GetCancellationToken(cancellationToken));
             if (entitys?.Count > 1)
             {
                 throw new UserFriendlyException("鏌ヨ鍒板鏉¤褰�");
@@ -206,10 +208,11 @@
         else
         {
             return await (await GetDbSetAsync())
-          .WhereIf(whereConditions != null, whereConditions)
-          .Where(x => !x.IsDeleted)
-          .OrderByDescending(x => x.$OrderBy$)
-          .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
+                .IncludeDetails()
+                .WhereIf(whereConditions != null, whereConditions)
+                .Where(x => !x.IsDeleted)
+                .OrderByDescending(x => x.$OrderBy$)
+                .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
         }
     }
 }

--
Gitblit v1.9.3