Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to get localized string in custom repository? #4192


User avatar
0
manojreddy created

I have a class TestRepository in which I want to get the localized string, but I get error >The name 'L' does not exist in the current context if I try

throw new UserFriendlyException(L("TestAlreadyExists"));
public class TestRepository : TestRepositoryBase<Test, int>, ITestRepository

1 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    The L helper is not defined for repositories.

    You can inject ILocalizationManager and define it:

    private string L(string name)
    {
        return _localizationManager.GetString(AbpZeroTemplateConsts.LocalizationSourceName, name);
    }