SkillAgentSearch skills...

ExpressionToWhereClause

The source codes of nuget package https://www.nuget.org/packages/ExpressionToWhereClause/

Install / Use

/learn @zhurongbo111/ExpressionToWhereClause
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

ExpressionToWhereClause.Net

A simple tool library for converting the Expression to sql where clause

Ask DeepWiki

Packages

NuGet feed: https://www.nuget.org/packages/ExpressionToWhereClause/

| Package | NuGet Stable | NuGet Pre-release | Downloads | | ------- | ------------ | ----------------- | --------- | | ExpressionToWhereClause | ExpressionToWhereClause | ExpressionToWhereClause | ExpressionToWhereClause |

Features

ExpressionToWhereClause is a NuGet library that you can add into your project that will extend your Expression<Func<TModel, bool>> type.

It provides only one Method:

Explain of Type Expression<Func<TModel, bool>> to the parametric sql where clause and the parameter list

 public static (string, Dictionary<string, object>) ToWhereClause<T>(this Expression<Func<T, bool>> expression, ISqlAdapter sqlAdapter = default) where T : class

The the right part of Func<TModel, bool> must like:

[model].[PropertyName] [comparator] [Value], or the combinations.

Example:

u.Name == "Foo"

Or

u.Name == "Foo" || u.Name == "Bar"

The [Value] can be from many places, not only the constant. For the detailed information, please see the example usage.

Warning: This library dose not support unary, like u => !(u.Name == "Foo"), but support u => u.Name != "Foo" and u => !u.Sex Sex is bool type

Example usage:

See the Unit Test

View on GitHub
GitHub Stars5
CategoryData
Updated10mo ago
Forks4

Languages

C#

Security Score

82/100

Audited on May 23, 2025

No findings