mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-10 02:10:55 +08:00
Updated 表达式函数 (markdown)
19
表达式函数.md
19
表达式函数.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<Func<T, bool>> where = a => a.id == Guid.Empty;
|
||||
where = where.And(b => b.num > 0);
|
||||
where = where.Or(b => b.num > 0);
|
||||
```
|
||||
|
||||
动态拼Or.先搞个false条件 然后拼Lambda条件
|
||||
```
|
||||
Expression<Func<T, bool>> where = a =>false;
|
||||
if(xxx)
|
||||
{
|
||||
where = where.Or(b => b.num > 0);
|
||||
}
|
||||
```
|
||||
|
||||
## In查询
|
||||
|
||||
```csharp
|
||||
|
||||
Reference in New Issue
Block a user