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 类型用法示例:
查看单元测试