From 6bbe723eac052cb977d96a70c7deb5cf429173d6 Mon Sep 17 00:00:00 2001 From: IGeekFan Date: Mon, 30 Nov 2020 20:18:25 +0800 Subject: [PATCH] =?UTF-8?q?Updated=20=E8=A1=A8=E8=BE=BE=E5=BC=8F=E5=87=BD?= =?UTF-8?q?=E6=95=B0=20(markdown)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 表达式函数.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/表达式函数.md b/表达式函数.md index cb9c4ba..43a1dd0 100644 --- a/表达式函数.md +++ b/表达式函数.md @@ -1,5 +1,24 @@ 这是 FreeSql 非常特色的功能之一,深入细化函数解析,所支持的类型基本都可以使用对应的表达式函数,例如 日期、字符串、IN查询、数组(PostgreSQL的数组)、字典(PostgreSQL HStore)等等。 +## 动态Lambda表达式 +- And、Or扩展方法 [LambadaExpressionExtensions.cs](https://github.com/dotnetcore/FreeSql/blob/master/FreeSql/Extensions/LambadaExpressionExtensions.cs) + +示例 +``` +Expression> where = a => a.id == Guid.Empty; +where = where.And(b => b.num > 0); +where = where.Or(b => b.num > 0); +``` + +动态拼Or.先搞个false条件 然后拼Lambda条件 +``` +Expression> where = a =>false; +if(xxx) +{ + where = where.Or(b => b.num > 0); +} +``` + ## In查询 ```csharp