Skip to content

Commit 95309bb

Browse files
committed
Removed unnecessary Assume()
There were a number of unnecessary `Assume()` checks. These are necessary when checking fields that could be `null`. Since the database columns these are checking are not nullable, however, this condition should never happen. And, if it does, the `SqlDataReader` extension methods will likely throw an exception before these `Assume()` methods are ever called, since most of the `SqlDataReader` extensions are (by design) not aware of `DBNull`.
1 parent 42b6c84 commit 95309bb

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

OnTopic.Data.Sql/SqlTopicRepository.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,10 @@ private static void SetIndexedAttributes(SqlDataReader reader, Dictionary<int, T
109109
version = reader.GetVersion();
110110
}
111111

112-
/*------------------------------------------------------------------------------------------------------------------------
113-
| Validate conditions
114-
\-----------------------------------------------------------------------------------------------------------------------*/
115-
Contract.Assume(id, $"The 'TopicID' field is missing from the topic. This is an unexpected condition.");
116-
Contract.Assume(name, $"The 'AttributeKey' field is missing from the topic. This is an unexpected condition.");
117-
118112
/*------------------------------------------------------------------------------------------------------------------------
119113
| Handle empty attributes (treat empty as null)
120114
\-----------------------------------------------------------------------------------------------------------------------*/
121-
if (String.IsNullOrEmpty(value) || DBNull.Value.Equals(value)) return;
115+
if (String.IsNullOrEmpty(attributeValue)) return;
122116

123117
/*------------------------------------------------------------------------------------------------------------------------
124118
| Identify topic
@@ -158,11 +152,6 @@ private static void SetExtendedAttributes(SqlDataReader reader, Dictionary<int,
158152
version = reader.GetVersion();
159153
}
160154

161-
/*------------------------------------------------------------------------------------------------------------------------
162-
| Validate conditions
163-
\-----------------------------------------------------------------------------------------------------------------------*/
164-
Contract.Assume(id, $"The 'TopicID' field is missing from the topic. This is an unexpected condition.");
165-
166155
/*------------------------------------------------------------------------------------------------------------------------
167156
| Load SQL XML into XmlDocument
168157
\-----------------------------------------------------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)