TObject ConstructObject(IReadOnlyDictionary <string, object?>?row, int?rowCount) { if (rowCount == 0 || row == null) { throw new MissingDataException($"No rows were returned. It was this expected, use `.ToObjectOrNull` instead of `.ToObject`."); } else if (rowCount > 1 && !m_RowOptions.HasFlag(RowOptions.DiscardExtraRows)) { throw new UnexpectedDataException($"Expected 1 row but received {rowCount} rows. If this was expected, use `RowOptions.DiscardExtraRows`."); } return(MaterializerUtilities.ConstructObject <TObject>(row, Constructor)); }
TObject?ConstructObject(IReadOnlyDictionary <string, object?>?row, int?rowCount) { if (rowCount == 0 || row == null) { if (!m_RowOptions.HasFlag(RowOptions.PreventEmptyResults)) { return(null); } else { throw new MissingDataException($"No rows were returned and {nameof(RowOptions)}.{nameof(RowOptions.PreventEmptyResults)} was enabled."); } } else if (rowCount > 1 && !m_RowOptions.HasFlag(RowOptions.DiscardExtraRows)) { throw new UnexpectedDataException($"Expected 1 row but received {rowCount} rows. If this was expected, use `RowOptions.DiscardExtraRows`."); } return(MaterializerUtilities.ConstructObject <TObject>(row, Constructor)); }
private TObject ConstructObject(IReadOnlyDictionary <string, object> row, int?rowCount) { if (rowCount == 0) { if (m_RowOptions.HasFlag(RowOptions.AllowEmptyResults)) { return(null); } else { throw new MissingDataException("No rows were returned"); } } else if (rowCount > 1 && !m_RowOptions.HasFlag(RowOptions.DiscardExtraRows)) { throw new UnexpectedDataException($"Expected 1 row but received {rowCount} rows"); } return(MaterializerUtilities.ConstructObject <TObject>(row, ConstructorSignature)); }