mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
add test
This commit is contained in:
parent
c0a34b8c6b
commit
43585661ca
@ -13,6 +13,42 @@ namespace FreeSql.Tests
|
|||||||
{
|
{
|
||||||
public class UnitTest4
|
public class UnitTest4
|
||||||
{
|
{
|
||||||
|
[Fact]
|
||||||
|
public void SelectLambdaParameter()
|
||||||
|
{
|
||||||
|
using (var fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;min pool size=1;Max Pool Size=51")
|
||||||
|
.UseAutoSyncStructure(true)
|
||||||
|
.UseGenerateCommandParameterWithLambda(true)
|
||||||
|
.UseMonitorCommand(
|
||||||
|
cmd => Trace.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText) //监听SQL命令对象,在执行前
|
||||||
|
//, (cmd, traceLog) => Console.WriteLine(traceLog)
|
||||||
|
)
|
||||||
|
.Build())
|
||||||
|
{
|
||||||
|
fsql.Delete<ts_slp01>().Where("1=1").ExecuteAffrows();
|
||||||
|
|
||||||
|
var testItem = new ts_slp01();
|
||||||
|
var sql1 = fsql.Select<ts_slp01>().Where(a => a.name == testItem.GetTestName1()).ToSql();
|
||||||
|
var sql2 = fsql.Select<ts_slp01>().Where(a => a.name == testItem.GetTestName2()).ToSql();
|
||||||
|
|
||||||
|
Assert.Equal(@"SELECT a.[id], a.[name]
|
||||||
|
FROM [ts_slp01] a
|
||||||
|
WHERE (a.[name] = @exp_0)", sql1);
|
||||||
|
Assert.Equal(@"SELECT a.[id], a.[name]
|
||||||
|
FROM [ts_slp01] a
|
||||||
|
WHERE (a.[name] IS NULL)", sql2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class ts_slp01
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
|
||||||
|
public string GetTestName1() => "xxx";
|
||||||
|
public string GetTestName2() => null;
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void SelectN_SubSelectN()
|
public void SelectN_SubSelectN()
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ QQ Groups:4336577(full)、**8578575(available)**、**52508226(available)**
|
|||||||
|
|
||||||
| |
|
| |
|
||||||
| - |
|
| - |
|
||||||
| [基础入门](https://www.cnblogs.com/FreeSql/p/11531300.html) \| [Select](https://github.com/2881099/FreeSql/wiki/%e6%9f%a5%e8%af%a2) \| [Update](https://github.com/2881099/FreeSql/wiki/%e4%bf%ae%e6%94%b9) \| [Insert](https://github.com/2881099/FreeSql/wiki/%e6%b7%bb%e5%8a%a0) \| [Delete](https://github.com/2881099/FreeSql/wiki/%e5%88%a0%e9%99%a4) \| [FAQ](https://github.com/dotnetcore/FreeSql/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98) |
|
| [新手上路](https://www.cnblogs.com/FreeSql/p/11531300.html) \| [Select](https://github.com/2881099/FreeSql/wiki/%e6%9f%a5%e8%af%a2) \| [Update](https://github.com/2881099/FreeSql/wiki/%e4%bf%ae%e6%94%b9) \| [Insert](https://github.com/2881099/FreeSql/wiki/%e6%b7%bb%e5%8a%a0) \| [Delete](https://github.com/2881099/FreeSql/wiki/%e5%88%a0%e9%99%a4) \| [FAQ](https://github.com/dotnetcore/FreeSql/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98) |
|
||||||
| [Expression](https://github.com/2881099/FreeSql/wiki/%e8%a1%a8%e8%be%be%e5%bc%8f%e5%87%bd%e6%95%b0) \| [CodeFirst](https://github.com/2881099/FreeSql/wiki/CodeFirst) \| [DbFirst](https://github.com/2881099/FreeSql/wiki/DbFirst) \| [Filters](https://github.com/2881099/FreeSql/wiki/%e8%bf%87%e6%bb%a4%e5%99%a8) \| [AOP](https://github.com/2881099/FreeSql/wiki/AOP) |
|
| [Expression](https://github.com/2881099/FreeSql/wiki/%e8%a1%a8%e8%be%be%e5%bc%8f%e5%87%bd%e6%95%b0) \| [CodeFirst](https://github.com/2881099/FreeSql/wiki/CodeFirst) \| [DbFirst](https://github.com/2881099/FreeSql/wiki/DbFirst) \| [Filters](https://github.com/2881099/FreeSql/wiki/%e8%bf%87%e6%bb%a4%e5%99%a8) \| [AOP](https://github.com/2881099/FreeSql/wiki/AOP) |
|
||||||
| [Repository](https://github.com/2881099/FreeSql/wiki/Repository) \| [UnitOfWork](https://github.com/2881099/FreeSql/wiki/%e5%b7%a5%e4%bd%9c%e5%8d%95%e5%85%83) \| [DbContext](https://github.com/2881099/FreeSql/wiki/DbContext) \| [ADO](https://github.com/2881099/FreeSql/wiki/ADO) |
|
| [Repository](https://github.com/2881099/FreeSql/wiki/Repository) \| [UnitOfWork](https://github.com/2881099/FreeSql/wiki/%e5%b7%a5%e4%bd%9c%e5%8d%95%e5%85%83) \| [DbContext](https://github.com/2881099/FreeSql/wiki/DbContext) \| [ADO](https://github.com/2881099/FreeSql/wiki/ADO) |
|
||||||
| [Read/Write](https://github.com/2881099/FreeSql/wiki/%e8%af%bb%e5%86%99%e5%88%86%e7%a6%bb) \| [Splitting Table](https://github.com/2881099/FreeSql/wiki/%e5%88%86%e8%a1%a8%e5%88%86%e5%ba%93) \| [Hide tech](https://github.com/2881099/FreeSql/wiki/%E9%AA%9A%E6%93%8D%E4%BD%9C) \| [*Update Notes*](https://github.com/2881099/FreeSql/wiki/%e6%9b%b4%e6%96%b0%e6%97%a5%e5%bf%97) |
|
| [Read/Write](https://github.com/2881099/FreeSql/wiki/%e8%af%bb%e5%86%99%e5%88%86%e7%a6%bb) \| [Splitting Table](https://github.com/2881099/FreeSql/wiki/%e5%88%86%e8%a1%a8%e5%88%86%e5%ba%93) \| [Hide tech](https://github.com/2881099/FreeSql/wiki/%E9%AA%9A%E6%93%8D%E4%BD%9C) \| [*Update Notes*](https://github.com/2881099/FreeSql/wiki/%e6%9b%b4%e6%96%b0%e6%97%a5%e5%bf%97) |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user