mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
- 修复 GroupBy 之后 WithTempQuery 参数化时未传递的问题;
This commit is contained in:
parent
cb3009d2ca
commit
4a2f9eb77e
@ -47,6 +47,7 @@
|
||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.MySql\FreeSql.Provider.MySql.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.Oracle\FreeSql.Provider.Oracle.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.PostgreSQL\FreeSql.Provider.PostgreSQL.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.QuestDb\FreeSql.Provider.QuestDb.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.ShenTong\FreeSql.Provider.ShenTong.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.Sqlite\FreeSql.Provider.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.SqlServer\FreeSql.Provider.SqlServer.csproj" />
|
||||
|
@ -552,6 +552,29 @@
|
||||
保存或添加,如果主键有值则尝试 Update,如果影响的行为 0 则尝试 Insert
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:FreeSql.Tests.QuestDb.Utils.OrderAttribute">
|
||||
<summary>
|
||||
测试方法的执行顺序
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:FreeSql.Tests.QuestDb.Utils.OrderAttribute.Sort">
|
||||
<summary>
|
||||
顺序
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:FreeSql.Tests.QuestDb.Utils.TestOrders">
|
||||
<summary>
|
||||
单元测试的排序策略
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:FreeSql.Tests.QuestDb.Utils.TestOrders.OrderTestCases``1(System.Collections.Generic.IEnumerable{``0})">
|
||||
<summary>
|
||||
执行顺序
|
||||
</summary>
|
||||
<typeparam name="TTestCase"></typeparam>
|
||||
<param name="testCases"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:FreeSql.Tests.SqlServer.SqlServerCodeFirstTest.tbdot01">
|
||||
<summary>
|
||||
表中带点
|
||||
|
@ -1,4 +1,5 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@ -10,6 +11,51 @@ namespace FreeSql.Tests.SqlServer
|
||||
{
|
||||
#region issues #1215
|
||||
|
||||
[Fact]
|
||||
public void IssuesParameter01()
|
||||
{
|
||||
using (var fsql = new FreeSql.FreeSqlBuilder()
|
||||
.UseConnectionFactory(FreeSql.DataType.SqlServer, () => new SqlConnection("Data Source=.;Integrated Security=True;Initial Catalog=issues684;Pooling=true;Max Pool Size=36;TrustServerCertificate=true"))
|
||||
.UseAutoSyncStructure(true)
|
||||
.UseGenerateCommandParameterWithLambda(true)
|
||||
.Build())
|
||||
{
|
||||
fsql.Aop.CommandBefore += (_, e) =>
|
||||
{
|
||||
|
||||
};
|
||||
var qlrzjh = "qlrzjh";
|
||||
var qzh = "qzh";
|
||||
var sql = fsql.Select<QLR_TO_LSH>()
|
||||
.Where(a => a.QLRZJHM == qlrzjh && a.QZH == qzh)
|
||||
.GroupBy(a => new { a.QLRZJHM, a.QZH })
|
||||
.WithTempQuery(g => new { BBH = g.Min(g.Value.BBH), g.Key })
|
||||
.From<QLR_TO_LSH>()
|
||||
.InnerJoin((a, b) => a.BBH == b.BBH && b.QLRZJHM == qlrzjh && b.QZH == qzh)
|
||||
.ToSql((a, b) => b);
|
||||
Assert.Equal(@"SELECT b.[QLRZJHM] as1, b.[QZH] as2, b.[BBH] as3
|
||||
FROM (
|
||||
SELECT min(a.[BBH]) [BBH], a.[QLRZJHM], a.[QZH]
|
||||
FROM [QLR_TO_LSH] a
|
||||
WHERE (a.[QLRZJHM] = @exp_0 AND a.[QZH] = @exp_1)
|
||||
GROUP BY a.[QLRZJHM], a.[QZH] ) a
|
||||
INNER JOIN [QLR_TO_LSH] b ON a.[BBH] = b.[BBH] AND b.[QLRZJHM] = N'qlrzjh' AND b.[QZH] = N'qzh'", sql);
|
||||
fsql.Select<QLR_TO_LSH>()
|
||||
.Where(a => a.QLRZJHM == qlrzjh && a.QZH == qzh)
|
||||
.GroupBy(a => new { a.QLRZJHM, a.QZH })
|
||||
.WithTempQuery(g => new { BBH = g.Min(g.Value.BBH), g.Key })
|
||||
.From<QLR_TO_LSH>()
|
||||
.InnerJoin((a, b) => a.BBH == b.BBH && b.QLRZJHM == qlrzjh && b.QZH == qzh)
|
||||
.First();
|
||||
}
|
||||
}
|
||||
class QLR_TO_LSH
|
||||
{
|
||||
public string QLRZJHM { get; set; }
|
||||
public string QZH { get; set; }
|
||||
public int BBH { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VicDemo20220815()
|
||||
{
|
||||
|
@ -247,6 +247,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
ret._transaction = _select._transaction;
|
||||
ret._whereGlobalFilter = new List<GlobalFilter.Item>(_select._whereGlobalFilter.ToArray());
|
||||
ret._cancel = _select._cancel;
|
||||
ret._params.AddRange(_select._params);
|
||||
if (ret._tables[0].Table == null) ret._tables[0].Table = TableInfo.GetDefaultTable(typeof(TDto));
|
||||
Select0Provider.WithTempQueryParser parser = null;
|
||||
_addFieldAlias = true; //解决:[Column(Name = "flevel") 与属性名不一致时,嵌套查询 bug
|
||||
|
Loading…
x
Reference in New Issue
Block a user