Linq.PropertyTranslator.Core 1.0.5.1

dotnet add package Linq.PropertyTranslator.Core --version 1.0.5.1
                    
NuGet\Install-Package Linq.PropertyTranslator.Core -Version 1.0.5.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="Linq.PropertyTranslator.Core" Version="1.0.5.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Linq.PropertyTranslator.Core" Version="1.0.5.1" />
                    
Directory.Packages.props
<PackageReference Include="Linq.PropertyTranslator.Core" />
                    
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 Linq.PropertyTranslator.Core --version 1.0.5.1
                    
#r "nuget: Linq.PropertyTranslator.Core, 1.0.5.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.
#addin nuget:?package=Linq.PropertyTranslator.Core&version=1.0.5.1
                    
Install as a Cake Addin
#tool nuget:?package=Linq.PropertyTranslator.Core&version=1.0.5.1
                    
Install as a Cake Tool

Linq.PropertyTranslator.Core

This is a .NET Core / .NET Standard port of the PropertyTranslator (https://github.com/peschuster/PropertyTranslator).

The following frameworks are supported:

  • net40
  • net45
  • net45x
  • net46
  • netstandard1.3
  • netstandard2.0

Translates computed properties in LINQ queries into their implementation (based on Microsoft.Linq.Translations).

What does it?

PropertyTranslator exchanges properties in linq queries before execution. This is especially useful if the underlying LINQ provider does not support some kind of operation or you want to add client-side calculations in your business logic to e.g. an EntityFramework model.

For a general introduction into the topic, have a look at this blog post. PropertyTranslator actually is a enhancement of the presented solution in the post.

For an introduction specifically to PropertyTranslator have a look at these two blog posts: LINQ: How to dynamically map properties and PropertyTranslator and Interfaces

What's the difference to Linq.Translations?

PropertyTranslator plays well together with QueryInterceptor.Core and thus can be added to every query in some kind of "data context" or general table / ObjectSet provider.

Furthermore it internally adds one more layer of abstraction to allow property translation depending on the ui culture of the current thread.

Examples

Basic example

A POCO entity class from EntityFramework. Although in the database only a FirstName and a LastName field exists, the property Name can be used in queries, because right before execution of the query it is translated to FirstName + ' ' + LastName.

public class Person
{
    private static readonly CompiledExpressionMap<Person, string> fullNameExpression = 
        DefaultTranslationOf<Person>.Property(p => p.FullName).Is(p => p.FirstName + " " + p.LastName);
    	    
    public string FullName
    {
        get { return fullNameExpression.Evaluate(this); }
    }
    	
    public string FirstName { get; set; }
    	
    public string LastName { get; set; }    	
}
A more advanced example with ui culture dependent translations

The context: a database table, mapped with entity framework to POCO entity classes with two fields: EnglishName and GermanName. With the following snippet, you can use the Name property in linq queries which resolves to the name (either EnglishName or GermanName) depending on the current ui culture.

public class Country
{
    private static readonly CompiledExpressionMap<Country, string> nameExpression = 
    	DefaultTranslationOf<Country>.Property(c => c.Name).Is(c => c.EnglishName);
    	
    static Country()
    {
    	DefaultTranslationOf<Country>.Property(c => c.Name).Is(c => c.EnglishName, 'en');
    	DefaultTranslationOf<Country>.Property(c => c.Name).Is(c => c.GermanName, 'de');
    }    	
    	
    public string Name
    {
    	get { return nameExpression.Evaluate(this); }
    }
    	
    public string EnglishName { get; set; }
    	
    public string GermanName { get; set; }    	
}

How to enable PropertyTranslator

You can enable PropertyTranslator by adding the PropertyVisitor to your EntityFramework ObjectSets (of course it works not only with EntityFramework but with any LINQ provider):

using QueryInterceptor;
using PropertyTranslator;

public class MyDataContext
{
    ObjectContext context = new MyEfContext();
        
    public IQueryable<Person> PersonTable
    {
        get
        {
            var objectSet = context.CreateObjectSet<Person>("Persons");
                
            return objectSet.InterceptWith(new PropertyVisitor());
        }
    }
}

Sponsors

Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of Linq.PropertyTranslator.Core.

Entity Framework Extensions

Dapper Plus

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 is compatible.  net452 is compatible.  net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Linq.PropertyTranslator.Core:

Repository Stars
zzzprojects/System.Linq.Dynamic.Core
The .NET Standard / .NET Core version from the System Linq Dynamic functionality.
Version Downloads Last Updated
1.0.5.1 124 6/22/2025
1.0.5 28,101 12/1/2018
1.0.4 3,990 11/1/2017
1.0.3 4,686 10/4/2016
1.0.1 2,172 5/15/2016
1.0.0 1,383 4/20/2016

See CHANGELOG.MD