public void ToObjects_WithPrivateConstructor_CanMapObjects() { var guid = new Guid("07494404-072A-4BE3-962E-AA3E839AD330"); var dataTable = DataTableFactory.GenerateEmptyDataTableMatchingObjectProperties <PrivateConstructorPublicProperty>(); var dataRow = dataTable.NewRow(); dataRow["Id"] = guid; dataTable.Rows.Add(dataRow); var mappings = MappingHelper.CreatePropertyMappingsMatchingTable <PrivateConstructorPublicProperty>(dataTable); var results = dataTableResolver.ToObjects <PrivateConstructorPublicProperty>(DataTableFactory.RowsForTable(dataTable), new DefaultDataTypeConverter(), mappings, defaultSettings); Assert.Equal(1, results.Count); Assert.Equal(guid, results.Single().Id); }
public virtual IList <T> ConvertToType <T>(DataTable dataTable) { if (ReturnNullFromInput(dataTable)) { return(null); } if (InputIsEmpty(dataTable)) { return(ReturnFromEmptyInput <T>(dataTable)); } ExtendedPropertyInfo[] mappedProperties = mappingResolver.GetPropertyMappings <T>(dataTable, dataTableParserSettings); var dataRows = new DataRow[dataTable.Rows.Count]; dataTable.Rows.CopyTo(dataRows, 0); return(dataTableResolver.ToObjects <T>(dataRows, dataTypeConverter, mappedProperties, dataTableParserSettings)); }