public static PropertyDataRetrieversCollection ToPropertyDataRetrievers(this DocumentEntityDefinition definition) { var entityProperties = new PropertyDataRetrieversCollection(); foreach (var fieldDefinition in definition.FieldMappings.Values) { var valueType = fieldDefinition.ParserDefinition.FinalType; IValueConverter converter = null; if (valueType == typeof(DateTime)) { converter = new DateTimeValueConverter(fieldDefinition.ParserDefinition.ParsingFormats); } var sourceValueRetriever = new RowValueRetriever(fieldDefinition.Name) { Converter = converter }; var retriever = new PropertyDataRetriever(fieldDefinition.Name, sourceValueRetriever); entityProperties.Add(retriever); } return(entityProperties); }
private static string CreateSelectQuery(DocumentEntityDefinition definition) { var query = String.Empty; foreach (var field in definition.FieldMappings.Values.OrderBy(r => r.SourceOrdinal)) { query += string.Format("IIf(IsNull([F{0}]), Null, CStr([F{0}])) as F{0},", field.SourceOrdinal + 1); } if (query.Length == 0) { // there where no fields return(string.Format("Select * From [{0}]", definition.Range)); } query = query.Substring(0, query.Length - 1); return(string.Format("Select {1} From [{0}]", definition.Range, query)); }
public OleDbRowsCollectionReaderFactory(string workbookPath, DocumentEntityDefinition definition) { _workbookPath = workbookPath; _definition = definition; }