question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[CreateMultiLingualMap] Id of the entity is replaced by the id of the translation in the mapping

See original GitHub issue

Problem (using the documentation example)

While using the new (awesome and much anticipated btw) Multi Lingual Entities feature, i needed to get the id of the product with the translated name in the ProductListDto class.

public class ProductListDto: EntityDto
{
    // Mapped from Product.Price
    public decimal Price { get; set; }

    // Mapped from ProductTranslation.Name
    public string Name { get; set; }
}

I’m getting the correct translation for name but the Id (from EntityDto) is getting the ProductTranslation Id not the Product one (using CoreId as a property does the Job of getting the correct one instead)

Suggestion

If i understand correctly, in the CreateMultiLingualMap extention, in the aftermap, we check if there is a Translation so we map it and at the same time it replace the id.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ismcagdascommented, Jun 7, 2019

@valleen I think I have found the issue but this is an EF Core problem. When you clear the Translations while you are updating your entity, it is not removed from database and probably still exist in the change tracking. So, if you change your update method like this, it will work.

public override async Task<CategoryDto> Update(CategoryDto input)
{
	CheckUpdatePermission();

	var category = await _categoryRepository
		.GetAllIncluding(c => c.Translations)
		.FirstOrDefaultAsync(c => c.Id == input.Id);

	category.Translations.Clear();

	await UnitOfWorkManager.Current.SaveChangesAsync();

	ObjectMapper.Map(input, category);

	await _categoryManager.UpdateAsync(category);

	return await Get(input);
}
1reaction
ismcagdascommented, May 23, 2018

@valleen sure.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multi-Lingual Entities
This extension method finds the translation with selected UI language first. ... CreateMultiLingualMap also allows you to define type of the id field...
Read more >
Projection or Custom Value Resolvers with new Multi ...
If I put the Projection or Resolver after the CreateMultiLingualMap then the ItemCount maps correctly but the CatalogItemName fails to map. How ...
Read more >
Update existing 'node' entity while changing the ID is not ...
Try to sort the view result in a way that makes the translated entity appears after the original one. Proposed resolution. I attached...
Read more >
How to Design Multi-Lingual Entity - ABP Community
We don't need to change anything in the UI, if there is a translation according to the language chosen by the user, the...
Read more >
Entity Links fields does not have translation support
The Entity link field uses the wrong translation of the entity. It always uses the original language which is not always desired. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found