mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
添加新的多表查询语法,简化 定义 一堆 abcd
This commit is contained in:
@ -380,7 +380,7 @@ WHERE ROWNUM < 11";
|
||||
|
||||
|
||||
var xxxhzytuple = g.sqlserver.Select<Templates, TaskBuild>()
|
||||
.Where(a => a.Item1.Code == "xxx" && a.Item2.OptionsEntity03 == true)
|
||||
.Where(a => a.t1.Code == "xxx" && a.t2.OptionsEntity03 == true)
|
||||
.ToSql();
|
||||
|
||||
|
||||
|
50
FreeSql.Tests/FreeSql.Tests/UnitTest4.cs
Normal file
50
FreeSql.Tests/FreeSql.Tests/UnitTest4.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Xunit;
|
||||
using static FreeSql.Tests.UnitTest1;
|
||||
|
||||
namespace FreeSql.Tests
|
||||
{
|
||||
public class UnitTest4
|
||||
{
|
||||
static Lazy<IFreeSql> sqliteLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
|
||||
.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document.db;Attachs=xxxtb.db;")
|
||||
//.UseConnectionFactory(FreeSql.DataType.Sqlite, () =>
|
||||
//{
|
||||
// var conn = new System.Data.SQLite.SQLiteConnection(@"Data Source=|DataDirectory|\document.db;Pooling=true;");
|
||||
// //conn.Open();
|
||||
// //var cmd = conn.CreateCommand();
|
||||
// //cmd.CommandText = $"attach database [xxxtb.db] as [xxxtb];\r\n";
|
||||
// //cmd.ExecuteNonQuery();
|
||||
// //cmd.Dispose();
|
||||
// return conn;
|
||||
//})
|
||||
.UseAutoSyncStructure(true)
|
||||
//.UseGenerateCommandParameterWithLambda(true)
|
||||
.UseLazyLoading(true)
|
||||
.UseMonitorCommand(
|
||||
cmd => Trace.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText) //监听SQL命令对象,在执行前
|
||||
//, (cmd, traceLog) => Console.WriteLine(traceLog)
|
||||
)
|
||||
.Build());
|
||||
public static IFreeSql sqlite => sqliteLazy.Value;
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestHzyTuple()
|
||||
{
|
||||
var xxxhzytuple = g.sqlite.Select<Templates, TaskBuild>()
|
||||
.LeftJoin(w => w.t1.Id2 == w.t2.TemplatesId)
|
||||
.Where(w => w.t1.Code == "xxx" && w.t2.OptionsEntity03 == true)
|
||||
.OrderBy(w => w.t1.AddTime)
|
||||
.ToSql();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user