From 330abdf8979caba30965e7160c3797fe7f0eaf44 Mon Sep 17 00:00:00 2001
From: 2881099 <2881099@qq.com>
Date: Tue, 8 Nov 2022 00:33:39 +0800
Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=20PgArrayToMany=20DTO=20?=
=?UTF-8?q?=E5=BC=82=E6=AD=A5=E6=9F=A5=E8=AF=A2=E6=8A=A5=E9=94=99=E7=9A=84?=
=?UTF-8?q?=20bug=EF=BC=88=E5=90=8C=E6=AD=A5=E6=96=B9=E6=B3=95=E6=AD=A3?=
=?UTF-8?q?=E5=B8=B8=EF=BC=89=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FreeSql.DbContext/FreeSql.DbContext.xml | 9 +++++++++
.../CommonProvider/SelectProvider/Select1Provider.cs | 11 +++++++++++
README.md | 2 +-
README.zh-CN.md | 2 +-
4 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/FreeSql.DbContext/FreeSql.DbContext.xml b/FreeSql.DbContext/FreeSql.DbContext.xml
index 537315e2..26522f10 100644
--- a/FreeSql.DbContext/FreeSql.DbContext.xml
+++ b/FreeSql.DbContext/FreeSql.DbContext.xml
@@ -800,5 +800,14 @@
+
+
+ 批量注入 Repository,可以参考代码自行调整
+
+
+
+
+
+
diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs
index 87e67899..7b5c2a13 100644
--- a/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs
+++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select1Provider.cs
@@ -1536,6 +1536,17 @@ namespace FreeSql.Internal.CommonProvider
var bindings = new List();
if (imni.IsOutputPrimary) bindings.AddRange(imni.Table.Primarys.Select(a => Expression.Bind(imni.Table.Properties[a.CsName], Expression.MakeMemberAccess(imni.CurrentExpression, imni.Table.Properties[a.CsName]))));
if (imni.Childs.Any()) bindings.AddRange(imni.Childs.Select(a => Expression.Bind(imni.Table.Properties[a.Key], GetIncludeManyNewInitExpression(a.Value))));
+ var pgarrayToManys = imni.Table.GetAllTableRef().Select(tr =>
+ {
+ if (tr.Value.RefType != TableRefType.PgArrayToMany) return null;
+ var reftb = _orm.CodeFirst.GetTableByEntity(tr.Value.RefEntityType);
+ if (tr.Value.RefColumns[0] == reftb.Primarys[0])
+ {
+ bindings.Add(Expression.Bind(imni.Table.Properties[tr.Value.Columns[0].CsName], Expression.MakeMemberAccess(imni.CurrentExpression, imni.Table.Properties[tr.Value.Columns[0].CsName])));
+ return tr.Key;
+ }
+ return null;
+ }).ToList();
return Expression.MemberInit(imni.Table.Type.InternalNewExpression(), bindings);
}
diff --git a/README.md b/README.md
index 4efd04ac..0b8f0bfd 100644
--- a/README.md
+++ b/README.md
@@ -210,7 +210,7 @@ constantine,
[mafeng8](https://github.com/mafeng8),
[VicBilibily](https://github.com/VicBilibily),
[Soar](https://github.com/sgf),
-QLR etc.
+[quzhen91](https://github.com/quzhen91) etc.
## 💕 Donation
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 5fd8c7a5..072e4001 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -211,7 +211,7 @@ constantine,
[mafeng8](https://github.com/mafeng8),
[VicBilibily](https://github.com/VicBilibily),
[Soar](https://github.com/sgf),
-QLR 等。
+[quzhen91](https://github.com/quzhen91) 等。
## 💕 Donation (捐赠)