public static object Evaluate(string sourceFieldName, EtlValueTranslation sourceFieldTranslation, IDataRecord sourceRecord, string defaultValue) { if (sourceRecord == null) { throw new ArgumentNullException("sourceRecord"); } var sourceFieldValue = GetTranslatedFieldValue(sourceFieldName, sourceFieldTranslation, sourceRecord); if (sourceFieldValue == null || sourceFieldValue == DBNull.Value) { return(defaultValue); } else { return(sourceFieldValue); } }
private static object GetTranslatedFieldValue(string sourceFieldName, EtlValueTranslation sourceFieldTranslation, IDataRecord sourceRecord) { if (string.IsNullOrEmpty(sourceFieldName)) { return(null); } var sourceFieldValue = sourceRecord[sourceFieldName]; var translatedValue = sourceFieldValue; if (sourceFieldTranslation != null) { try { foreach (var func in sourceFieldTranslation.Functions) { translatedValue = func.Evaluate(translatedValue, sourceRecord); } return(translatedValue); } catch (Exception exc) { throw new InvalidOperationException ( string.Format ( Properties.Resources.ValueTranslationError, sourceFieldName, sourceFieldValue ), exc ); } } return(translatedValue); }
public static object Evaluate(string sourceFieldName, EtlValueTranslation sourceFieldTranslation, IDataRecord sourceRecord) { return(Evaluate(sourceFieldName, sourceFieldTranslation, sourceRecord, null)); }