efext 1.1.1

dotnet add package efext --version 1.1.1
                    
NuGet\Install-Package efext -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="efext" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="efext" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="efext" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add efext --version 1.1.1
                    
#r "nuget: efext, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package efext@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=efext&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=efext&version=1.1.1
                    
Install as a Cake Tool

efext

Build

Entity Framework Extensions

.NET library with utility extensions for between operations.

Installation

Install the package from nuget

https://nuget.org/packages/efext/

and add the using directive

using EfExt;

GreaterThan

public static IQueryable<TSource> GreaterThan<TSource>(
            this IQueryable<TSource> source,
            Expression<Func<TSource, string>> keySelector,
            string value)

Returns a subset where a given string column is greater than the given argument

GreaterThanOrEqual

Same as GreaterThan but inclusive

LessThan

Opposite of GreaterThan

LessThanOrEqual

Opposite of GreaterThanOrEqual

Between

Between is the composite of GreaterThanOrEqual and LessThanOrEqual

There are two overloads for the Between method

  1. Find rows where a single column is between two strings
var subset = ctx.Numbers.Between(i => i.Number, "40401002", "40401004");

alternative

var subset = ctx.Numbers.Between("40401002", i => i.Number, "40401004");
  1. Find rows where a string is between two columns
var plan = ctx.NumberPlans.Between(
                    r => r.LowerNumber,
                    r => r.UpperNumber,
                    "40410003");

alternative

var plan = ctx.NumberPlans.Between(
                    r => r.LowerNumber,
                    "40410003",
                    r => r.UpperNumber);

Linq

Recursive

        public static IEnumerable<T> Recursive<T>(
            this T node, Func<T, IEnumerable<T>> selector)

This method can be used for traversing a tree structure. It will extend the node type, and the provided selector is used for finding the children, that must be of the same type as node (T).

Example
        [Test]
        public void NodeWithoutChildren()
        {
            var noChildren = _tree.Recursive(n => n.Children)
                                  .Where(n => n.Children.Empty());

            Assert.AreEqual(4, noChildren.Count());
        }

How to sort a id/parent object by it's hierarchy

[Test]
public void WithLookupFunction()
{
	var items = new[]
	{
		new Item(2, 1),
		new Item(3, 1),
		new Item(4, 2),
		new Item(1, 1),
		new Item(5, 1),
		new Item(6, 4)
	};

	var root = items.Single(x => x.Id == 1);

	var sortedByTree = root.Recursive(items.ChildSelector).ToList();

	var expected = new[] { 1, 2, 4, 6, 3, 5 };

	Assert.IsTrue(expected.SequenceEqual(sortedByTree.Select(i => i.Id)));
}

public class Item
{
	public int Id;
	public int Parent;

	public Item() { }
	public Item(int id, int parent)
	{
		Id = id;
		Parent = parent;
	}
}

public static class ItemExt
{
	public static IEnumerable<Item> ChildSelector(
		this IEnumerable<Item> source,
		Item item)
	{
		return source.Where(i => i.Parent == item.Id && i.Parent != i.Id);
	}
}

See the testproject for more examples.

https://twitter.com/mteinum

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 0 1/14/2026
1.1.0 88,903 10/4/2019
1.0.4 4,960 5/8/2013
1.0.3 1,823 4/25/2013
1.0.2 1,612 4/24/2013
1.0.1 1,604 4/24/2013
1.0.0 1,617 4/24/2013