ExpressionToWhereClause
1.0.0
一個簡單的工具庫,用於將表達式轉換為sql where子句
NuGet 來源:https://www.nuget.org/packages/ExpressionToWhereClause/
| 包裹 | NuGet 穩定版 | NuGet 預發行版 | 下載 |
|---|---|---|---|
| 表達式ToWhere子句 |
ExpressionToWhereClause 是一個 NuGet 函式庫,您可以將其新增至專案中,以擴充您的Expression<Func<TModel, bool>>類型。
它只提供了一種方法:
類型Expression<Func<TModel, bool>>對parametric sql where子句和參數列表的解釋
public static ( string , Dictionary < string , object > ) ToWhereClause < T > ( this Expression < Func < T , bool > > expression , ISqlAdapter sqlAdapter = default ) where T : class Func<TModel, bool>的右側部分必須如下:
[model].[PropertyName] [comparator] [Value]或組合。
例子:
u . Name == "Foo"或者
u . Name == "Foo" || u . Name == "Bar" [Value]可以來自很多地方,而不僅僅是常數。詳細資訊請參閱範例用法。
u => !(u.Name == "Foo") ,但支援u => u.Name != "Foo"和u => !u.Sex Sex 是 bool 類型用法範例:
查看單元測試