添加新的多表查询语法,简化 定义 一堆 abcd

This commit is contained in:
hzy
2020-11-03 23:05:11 +08:00
parent 8e67cb3d73
commit f3aa07abb6
34 changed files with 4022 additions and 554 deletions

View File

@ -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();

View 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();
}
}
}