I have two tables, one the main entity and the other a translation record for it in a specific language
Recipe
- Id | unique identifier
RecipeTranslation
- Id | unique identifier
- RecipeId | unique identifier
- LanguageCode | string
- Name | String
Given an array of language codes, does anyone know how I would make a query, searching this translation table for any records that should exists (but don't). There should be one record for each recipe & language code
The only parameter I would like to pass into the SELECT query would be an array of language codes
The pseudo code would be something like
- for each recipe
- check a translation record exists for each language code
- if it does not show me the recipe id and language code pair missing
This is my current solution
var result = from ingredient in _dbContext.Ingredients
join translation in _dbContext.IngredientTranslations
on new { IngredientId = ingredient.Id, LanguageCode = "uk" } equals new { translation.IngredientId, translation.LanguageCode }
into ingredientTranslation
from x in ingredientTranslation.DefaultIfEmpty()
where x == null
select new { IngredientId = ingredient.Id, LanguageCode = "uk" };
I am able to fetch per language code. so I am just looping through the language codes and running this to return me the records that do not exist