LabelKit is a .NET toolkit for parsing kubernetes-like label-selectors and using them to build filters, including query-expressions for EFCore (Postgr

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-04-30 16:00:02

LabelKit is a .NET toolkit for parsing kubernetes-like label-selectors and using them to build filters, including query-expressions for EFCore (PostgreSQL, MySql, SqlServer, Sqlite). Labels are name/value pairs that can be represented as dictionaries (name->value) or simple string collections (name+delimiter+value).

Any component implementing ILabelSelector (meaning it can provide a collection of selector-expressions) can be used to match offline.

LabelKit supports infrastructure for building expression-trees that can be used to filter IQueryables. Components implementing ILabelSelectorExpressionBuilder are responsible for creating Expressions from label-selectors. Different expression-builders are needed for different scenarios.

Example: If your labels are stored as JSONB (PostgreSQL), the resulting SQL query has to be vastly different from if they were stored as an array. Therefore, you need a different expression.

CollectionLabelSelectorExpressionBuilder produces expressions that should be translatable to SQL by EFCore providers supporting primitive-collections. However, you should also be able to use those expressions offline (compiled).

Leave a Comment