From 46c187e4462f4d1e020c52cced77f04a964f58b8 Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Sun, 16 Aug 2020 15:28:49 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E8=A1=A5=E5=85=85=20Ado.Net=20=E5=A4=9A?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E6=89=A9=E5=B1=95=E6=96=B9=E6=B3=95=20Select?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MySqlConnectionExtensionsTest.cs | 7 ++ FreeSql/Extensions/FreeSqlGlobalExtensions.cs | 110 ++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/MySqlConnectionExtensionsTest.cs b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/MySqlConnectionExtensionsTest.cs index c16eb020..7f4a3296 100644 --- a/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/MySqlConnectionExtensionsTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/AdoNetExtensions/MySqlConnectionExtensionsTest.cs @@ -1,6 +1,7 @@ using MySql.Data.MySqlClient; using System; using System.Collections.Generic; +using System.Diagnostics; using Xunit; namespace FreeSql.Tests.AdoNetExtensions.MySqlConnectionExtensions { @@ -10,6 +11,12 @@ namespace FreeSql.Tests.AdoNetExtensions.MySqlConnectionExtensions { public Methods() { g.mysql.CodeFirst.SyncStructure(); + using (var conn = new MySqlConnection(_connectString)) + { + var fsql = conn.GetIFreeSql(); + fsql.CodeFirst.IsNoneCommandParameter = true; + fsql.Aop.CommandBefore += (_, e) => Trace.WriteLine("SQL: " + e.Command.CommandText); + } } [Fact] diff --git a/FreeSql/Extensions/FreeSqlGlobalExtensions.cs b/FreeSql/Extensions/FreeSqlGlobalExtensions.cs index e72c637b..8870e1c3 100644 --- a/FreeSql/Extensions/FreeSqlGlobalExtensions.cs +++ b/FreeSql/Extensions/FreeSqlGlobalExtensions.cs @@ -674,6 +674,61 @@ SELECT "); /// 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 /// public static IDelete Delete(this IDbConnection that, object dywhere) where T1 : class => GetCrud(that).Delete(dywhere).WithConnection(that as DbConnection); + + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class => + GetCrud(that).Select().From((s, b) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class => + GetCrud(that).Select().From((s, b, c) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class => + GetCrud(that).Select().From((s, b, c, d) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class => + GetCrud(that).Select().From((s, b, c, d, e) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class => + GetCrud(that).Select().From((s, b, c, d, e, f) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbConnection that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class => + GetCrud(that).Select().From((s, b, c, d, e, f, g) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(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 => + GetCrud(that).Select().From((s, b, c, d, e, f, g, h) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(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 => + GetCrud(that).Select().From((s, b, c, d, e, f, g, h, i) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(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 => + GetCrud(that).Select().From((s, b, c, d, e, f, g, h, i, j) => s); #endregion #region IDbTransaction @@ -770,6 +825,61 @@ SELECT "); /// 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 /// public static IDelete Delete(this IDbTransaction that, object dywhere) where T1 : class => GetCrud(that).Delete(dywhere).WithTransaction(that as DbTransaction); + + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbTransaction that) where T1 : class where T2 : class => + GetCrud(that).Select().From((s, b) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbTransaction that) where T1 : class where T2 : class where T3 : class => + GetCrud(that).Select().From((s, b, c) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class => + GetCrud(that).Select().From((s, b, c, d) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class => + GetCrud(that).Select().From((s, b, c, d, e) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class => + GetCrud(that).Select().From((s, b, c, d, e, f) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(this IDbTransaction that) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class => + GetCrud(that).Select().From((s, b, c, d, e, f, g) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(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 => + GetCrud(that).Select().From((s, b, c, d, e, f, g, h) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(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 => + GetCrud(that).Select().From((s, b, c, d, e, f, g, h, i) => s); + /// + /// 多表查询 + /// + /// + public static ISelect Select(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 => + GetCrud(that).Select().From((s, b, c, d, e, f, g, h, i, j) => s); #endregion #endregion