Skip to content

Commit ade97b3

Browse files
committed
- 修复 Ado.Net 扩展方法的多表查询 bug;#592
1 parent 21d597b commit ade97b3

File tree

3 files changed

+82
-27
lines changed

3 files changed

+82
-27
lines changed

FreeSql.DbContext/FreeSql.DbContext.xml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using FreeSql.DataAnnotations;
2+
using Newtonsoft.Json;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.ComponentModel;
6+
using System.ComponentModel.DataAnnotations;
7+
using System.Diagnostics;
8+
using System.Reflection;
9+
using System.Text;
10+
using System.Threading;
11+
using Xunit;
12+
13+
namespace FreeSql.Tests.Issues
14+
{
15+
public class _592
16+
{
17+
[Fact]
18+
public void AdoNet()
19+
{
20+
using (var conn = g.mysql.Ado.MasterPool.Get())
21+
{
22+
var list = conn.Value.Select<park_sys_users, park_sys_userrole>()
23+
.LeftJoin((rs, le) => rs.user_id == le.ur_userid)
24+
.Where((rs, le) => rs.user_id > 0)
25+
.Count();
26+
}
27+
}
28+
29+
[Table(Name = "park_sys_users")]
30+
public partial class park_sys_users
31+
{
32+
public park_sys_users()
33+
{
34+
}
35+
36+
[Column(IsIdentity = true)]
37+
public int user_id { get; set; }
38+
public string user_loginname { get; set; }
39+
public string user_name { get; set; }
40+
public string user_pwd { get; set; }
41+
public int user_type { get; set; }
42+
public string user_spotid { get; set; }
43+
public string user_phone { get; set; }
44+
public string user_email { get; set; }
45+
public string user_remark { get; set; }
46+
public int user_specialrole { get; set; }
47+
public string user_createuser { get; set; }
48+
public DateTime user_createtime { get; set; }
49+
public int user_state { get; set; }
50+
public int user_managetype { get; set; }
51+
}
52+
53+
public partial class park_sys_userrole
54+
{
55+
public park_sys_userrole()
56+
{
57+
}
58+
59+
public int ur_id { get; set; }
60+
public int ur_userid { get; set; }
61+
public int ur_roleid { get; set; }
62+
}
63+
}
64+
}

FreeSql/Extensions/AdoNetExtensions.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -195,63 +195,63 @@ static IFreeSql GetCrud(IDbTransaction dbtran)
195195
/// <param name="that"></param>
196196
/// <returns></returns>
197197
public static ISelect<T1, T2> Select<T1, T2>(this IDbConnection that) where T1 : class where T2 : class =>
198-
GetCrud(that).Select<T1>().From<T2>((s, b) => s);
198+
Select<T1>(that).From<T2>((s, b) => s);
199199
/// <summary>
200200
/// 多表查询
201201
/// </summary>
202202
/// <param name="that"></param>
203203
/// <returns></returns>
204204
public static ISelect<T1, T2, T3> Select<T1, T2, T3>(this IDbConnection that) where T1 : class where T2 : class where T3 : class =>
205-
GetCrud(that).Select<T1>().From<T2, T3>((s, b, c) => s);
205+
Select<T1>(that).From<T2, T3>((s, b, c) => s);
206206
/// <summary>
207207
/// 多表查询
208208
/// </summary>
209209
/// <param name="that"></param>
210210
/// <returns></returns>
211211
public static ISelect<T1, T2, T3, T4> Select<T1, T2, T3, T4>(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class =>
212-
GetCrud(that).Select<T1>().From<T2, T3, T4>((s, b, c, d) => s);
212+
Select<T1>(that).From<T2, T3, T4>((s, b, c, d) => s);
213213
/// <summary>
214214
/// 多表查询
215215
/// </summary>
216216
/// <param name="that"></param>
217217
/// <returns></returns>
218218
public static ISelect<T1, T2, T3, T4, T5> Select<T1, T2, T3, T4, T5>(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class =>
219-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5>((s, b, c, d, e) => s);
219+
Select<T1>(that).From<T2, T3, T4, T5>((s, b, c, d, e) => s);
220220
/// <summary>
221221
/// 多表查询
222222
/// </summary>
223223
/// <param name="that"></param>
224224
/// <returns></returns>
225225
public static ISelect<T1, T2, T3, T4, T5, T6> Select<T1, T2, T3, T4, T5, T6>(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class =>
226-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6>((s, b, c, d, e, f) => s);
226+
Select<T1>(that).From<T2, T3, T4, T5, T6>((s, b, c, d, e, f) => s);
227227
/// <summary>
228228
/// 多表查询
229229
/// </summary>
230230
/// <param name="that"></param>
231231
/// <returns></returns>
232232
public static ISelect<T1, T2, T3, T4, T5, T6, T7> Select<T1, T2, T3, T4, T5, T6, T7>(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class =>
233-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6, T7>((s, b, c, d, e, f, g) => s);
233+
Select<T1>(that).From<T2, T3, T4, T5, T6, T7>((s, b, c, d, e, f, g) => s);
234234
/// <summary>
235235
/// 多表查询
236236
/// </summary>
237237
/// <param name="that"></param>
238238
/// <returns></returns>
239239
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8> Select<T1, T2, T3, T4, T5, T6, T7, T8>(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class =>
240-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6, T7, T8>((s, b, c, d, e, f, g, h) => s);
240+
Select<T1>(that).From<T2, T3, T4, T5, T6, T7, T8>((s, b, c, d, e, f, g, h) => s);
241241
/// <summary>
242242
/// 多表查询
243243
/// </summary>
244244
/// <param name="that"></param>
245245
/// <returns></returns>
246246
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> Select<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class =>
247-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6, T7, T8, T9>((s, b, c, d, e, f, g, h, i) => s);
247+
Select<T1>(that).From<T2, T3, T4, T5, T6, T7, T8, T9>((s, b, c, d, e, f, g, h, i) => s);
248248
/// <summary>
249249
/// 多表查询
250250
/// </summary>
251251
/// <param name="that"></param>
252252
/// <returns></returns>
253253
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Select<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class =>
254-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6, T7, T8, T9, T10>((s, b, c, d, e, f, g, h, i, j) => s);
254+
Select<T1>(that).From<T2, T3, T4, T5, T6, T7, T8, T9, T10>((s, b, c, d, e, f, g, h, i, j) => s);
255255
#endregion
256256

257257
#region IDbTransaction
@@ -365,55 +365,55 @@ public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Select<T1, T2, T3
365365
/// </summary>
366366
/// <returns></returns>
367367
public static ISelect<T1, T2> Select<T1, T2>(this IDbTransaction that) where T1 : class where T2 : class =>
368-
GetCrud(that).Select<T1>().From<T2>((s, b) => s);
368+
Select<T1>(that).From<T2>((s, b) => s);
369369
/// <summary>
370370
/// 多表查询
371371
/// </summary>
372372
/// <returns></returns>
373373
public static ISelect<T1, T2, T3> Select<T1, T2, T3>(this IDbTransaction that) where T1 : class where T2 : class where T3 : class =>
374-
GetCrud(that).Select<T1>().From<T2, T3>((s, b, c) => s);
374+
Select<T1>(that).From<T2, T3>((s, b, c) => s);
375375
/// <summary>
376376
/// 多表查询
377377
/// </summary>
378378
/// <returns></returns>
379379
public static ISelect<T1, T2, T3, T4> Select<T1, T2, T3, T4>(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class =>
380-
GetCrud(that).Select<T1>().From<T2, T3, T4>((s, b, c, d) => s);
380+
Select<T1>(that).From<T2, T3, T4>((s, b, c, d) => s);
381381
/// <summary>
382382
/// 多表查询
383383
/// </summary>
384384
/// <returns></returns>
385385
public static ISelect<T1, T2, T3, T4, T5> Select<T1, T2, T3, T4, T5>(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class =>
386-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5>((s, b, c, d, e) => s);
386+
Select<T1>(that).From<T2, T3, T4, T5>((s, b, c, d, e) => s);
387387
/// <summary>
388388
/// 多表查询
389389
/// </summary>
390390
/// <returns></returns>
391391
public static ISelect<T1, T2, T3, T4, T5, T6> Select<T1, T2, T3, T4, T5, T6>(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class =>
392-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6>((s, b, c, d, e, f) => s);
392+
Select<T1>(that).From<T2, T3, T4, T5, T6>((s, b, c, d, e, f) => s);
393393
/// <summary>
394394
/// 多表查询
395395
/// </summary>
396396
/// <returns></returns>
397397
public static ISelect<T1, T2, T3, T4, T5, T6, T7> Select<T1, T2, T3, T4, T5, T6, T7>(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class =>
398-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6, T7>((s, b, c, d, e, f, g) => s);
398+
Select<T1>(that).From<T2, T3, T4, T5, T6, T7>((s, b, c, d, e, f, g) => s);
399399
/// <summary>
400400
/// 多表查询
401401
/// </summary>
402402
/// <returns></returns>
403403
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8> Select<T1, T2, T3, T4, T5, T6, T7, T8>(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class =>
404-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6, T7, T8>((s, b, c, d, e, f, g, h) => s);
404+
Select<T1>(that).From<T2, T3, T4, T5, T6, T7, T8>((s, b, c, d, e, f, g, h) => s);
405405
/// <summary>
406406
/// 多表查询
407407
/// </summary>
408408
/// <returns></returns>
409409
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> Select<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class =>
410-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6, T7, T8, T9>((s, b, c, d, e, f, g, h, i) => s);
410+
Select<T1>(that).From<T2, T3, T4, T5, T6, T7, T8, T9>((s, b, c, d, e, f, g, h, i) => s);
411411
/// <summary>
412412
/// 多表查询
413413
/// </summary>
414414
/// <returns></returns>
415415
public static ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Select<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class =>
416-
GetCrud(that).Select<T1>().From<T2, T3, T4, T5, T6, T7, T8, T9, T10>((s, b, c, d, e, f, g, h, i, j) => s);
416+
Select<T1>(that).From<T2, T3, T4, T5, T6, T7, T8, T9, T10>((s, b, c, d, e, f, g, h, i, j) => s);
417417
#endregion
418418

419419
#endregion

0 commit comments

Comments
 (0)