多语言实体映射

时间:2018-11-22 10:05:29

标签: c# automapper aspnetboilerplate

public class Product : Entity, IMultiLingualEntity
{
    public virtual decimal Price { get; set; }
    public virtual int Stock { get; set; }
    public virtual ICollection<ProductTranslation> Translations { get; set; }
}


public class ProductTranslation : Entity, IEntityTranslation
{
    public virtual string Name { get; set; }
    public virtual Product Core { get; set; }
    public virtual int CoreId { get; set; }
    public virtual string Language { get; set; }
}

Dto

public class ProductCreateDto
{
    public decimal Price { get; set; }
    public int Stock { get; set; }
    public string Name { get; set; }
}

我如何映射ProductCreateDto => Product,以便为新条目插入新的ProductTranslation记录,并使用当前语言CultureInfo.CurrentUICulture.Name和ProductTranslation.Name = ProductCreateDto.Name

0 个答案:

没有答案