2 -
source | link

I'm building an Entity Framework Core-backed ASP.NET Core RESTful service and I have entities / models such as Product, Document etc with description in multiple languages. I want to be able to dynamically query Products with relative Documents by providing their basic information with translated descriptions (based on current UI culture set by headers/cookies etc)

Unfortunately EF Core's Include called on navigation properties can't be filtered like this:

_dbContext.Products
   .Include(p => p.Documents,
          d => d.Language.Equals(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName));

I know EF Core 2.1 has global filters now, which can be used to manage soft delete or multi-tenancy etc, but I need per-request filters by language (if needed).

So I'm wondering how do I accomplish such functionality and if there is any best practice for managing translations in EF Core 2.1 in general (e.g. via an [Owned] property, a navigation property with some extension for conditional include etc)

I'm building an Entity Framework Core-backed ASP.NET Core RESTful service and I have entities / models such as Product, Document etc with description in multiple languages. I want to be able to dynamically query Products with relative Documents by providing their basic information with translated descriptions (based on current UI culture set by headers/cookies etc)

Unfortunately EF Core's Include called on navigation properties can't be filtered like this:

_dbContext.Products
   .Include(p => p.Documents,
          d => d.Language.Equals(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName));

I know EF Core 2.1 has global filters now, which can be used to manage soft delete or multi-tenancy etc, but I need per-request filters by language (if needed).

So I'm wondering how do I accomplish such functionality and if there is any best practice for managing translations in EF Core 2.1 in general (e.g. via an [Owned] property)

I'm building an Entity Framework Core-backed ASP.NET Core RESTful service and I have entities / models such as Product, Document etc with description in multiple languages. I want to be able to dynamically query Products with relative Documents by providing their basic information with translated descriptions (based on current UI culture set by headers/cookies etc)

Unfortunately EF Core's Include called on navigation properties can't be filtered like this:

_dbContext.Products
   .Include(p => p.Documents,
          d => d.Language.Equals(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName));

I know EF Core 2.1 has global filters now, which can be used to manage soft delete or multi-tenancy etc, but I need per-request filters by language (if needed).

So I'm wondering how do I accomplish such functionality and if there is any best practice for managing translations in EF Core 2.1 in general (e.g. via an [Owned] property, a navigation property with some extension for conditional include etc)

1
source | link

Best practices for translatable models in Entity Framework Core 2.1+

I'm building an Entity Framework Core-backed ASP.NET Core RESTful service and I have entities / models such as Product, Document etc with description in multiple languages. I want to be able to dynamically query Products with relative Documents by providing their basic information with translated descriptions (based on current UI culture set by headers/cookies etc)

Unfortunately EF Core's Include called on navigation properties can't be filtered like this:

_dbContext.Products
   .Include(p => p.Documents,
          d => d.Language.Equals(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName));

I know EF Core 2.1 has global filters now, which can be used to manage soft delete or multi-tenancy etc, but I need per-request filters by language (if needed).

So I'm wondering how do I accomplish such functionality and if there is any best practice for managing translations in EF Core 2.1 in general (e.g. via an [Owned] property)