EntityTranslation<TEntity> Class
Namespace: PTS.Modules.EntityTranslationComponent
Assembly: PTS.Modules.EntityTranslationComponent.dll
Holds property translations for specified entity type.
Syntax
public class EntityTranslation<TEntity> : PropertyTranslationCollection, IReadOnlyCollection<PropertyTranslation>, IEnumerable<PropertyTranslation>, IEnumerable
Type Parameters
Name | Description |
---|---|
TEntity |
Implements
Constructors
EntityTranslation(LanguageCode)
Creates a new instance with optional default language as parameter.
Declaration
public EntityTranslation(LanguageCode defaultLanguage = LanguageCode.NotSet)
Parameters
Type | Name | Description |
---|---|---|
LanguageCode | defaultLanguage | Language that will be used to retrive and set property translations if not specified in calling methods. |
EntityTranslation(IEnumerable<IPropertyTranslation>, LanguageCode)
Creates a new instance filled with translations from supplied collection, with optional default language as parameter.
Declaration
public EntityTranslation(IEnumerable<IPropertyTranslation> translations, LanguageCode defaultLanguage = LanguageCode.NotSet)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IPropertyTranslation> | translations | Translations to fill into the newly created instance. |
LanguageCode | defaultLanguage | Language that will be used to retrive and set property translations if not specified in calling methods. |
Methods
Property(Expression<Func<TEntity, String>>, LanguageCode)
Retrieves translation for specified entity property in specified language.
Declaration
public PropertyTranslation Property(Expression<Func<TEntity, string>> property, LanguageCode language = LanguageCode.NotSet)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TEntity, System.String>> | property | Expression identifying the entity property to get the translation for. |
LanguageCode | language | Translation language to look for, if not set, collection default or common language will be used. |
Returns
Type | Description |
---|---|
PropertyTranslation | Entity property translation value in specified language or collection default language. |
SetProperty(Expression<Func<TEntity, String>>, String, LanguageCode)
Sets the translation value for specified property in specified language.
Declaration
public EntityTranslation<TEntity> SetProperty(Expression<Func<TEntity, string>> property, string value, LanguageCode language = LanguageCode.NotSet)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TEntity, System.String>> | property | Expression identifying the entity property to set the translation for. |
System.String | value | Translated value for specified property. |
LanguageCode | language | Translation language to set the value for, if not set, collection default language will be used. |
Returns
Type | Description |
---|---|
EntityTranslation<TEntity> | The same instance of current class for chaining. |