public virtual IEnumerable <PropertyValue> ToModel(PropertyValue propValue) { if (propValue == null) { throw new ArgumentNullException(nameof(propValue)); } propValue.Id = Id; propValue.CreatedBy = CreatedBy; propValue.CreatedDate = CreatedDate; propValue.ModifiedBy = ModifiedBy; propValue.ModifiedDate = ModifiedDate; propValue.OuterId = OuterId; propValue.LanguageCode = Locale; propValue.PropertyName = Name; propValue.ValueId = DictionaryItemId; propValue.ValueType = (PropertyValueType)ValueType; propValue.Value = DictionaryItem != null ? DictionaryItem.Alias : GetValue(propValue.ValueType); propValue.Alias = DictionaryItem?.Alias; //Need to expand all dictionary values if (DictionaryItem != null && !DictionaryItem.DictionaryItemValues.IsNullOrEmpty()) { foreach (var dictItemValue in DictionaryItem.DictionaryItemValues) { var dictPropValue = propValue.Clone() as PropertyValue; dictPropValue.Alias = DictionaryItem.Alias; dictPropValue.ValueId = DictionaryItem.Id; dictPropValue.LanguageCode = dictItemValue.Locale; dictPropValue.Value = dictItemValue.Value; yield return(dictPropValue); } } else { yield return(propValue); } }