I have the lines
if(query.GetRecordsFromResults() != null)
RecordsList.AddRange(query.GetRecordsFromResults());
Where GetRecordsFromResults()
returns IList<IRecord>
. Despite the if condition, i get System.ArgumentNullException
. Why is that ?
The faulty method :
foreach (var query in QueryList)
{
query.ExecutePreparedQuery();
if(query.GetRecordsFromResults() != null)
RecordsList.AddRange(query.GetRecordsFromResults());
}
QueryList
is a List<Query>
, query
is a Query
. Both are implemented, instantiated and initialised (verified).
public override IList<IRecords> GetRecordsFromResults()
{
var recordsList = new List<IRecords>();
if (Result != null && Result.Count != 0)
{
RecordBuilder.Value = Result.Count;
RecordBuilder.Querytype = QueryDescription();
RecordBuilder.Dateformatted = DateFormatting();
RecordBuilder.WebTitle = Web.Title;
recordsList.Add(RecordBuilder.BuildRecord());
return recordsList;
}
RecordBuilder.Value = 0;
RecordBuilder.Querytype = QueryDescription();
RecordBuilder.Dateformatted = DateFormatting();
RecordBuilder.WebTitle = Web.Title;
recordsList.Add(RecordBuilder.BuildRecord());
return recordsList;
}
Result
is a Query
's property, updated during the call of Query.ExecutePreparedQuery
. It may be null if the query failed.
RecordBuilder
is a builder for IRecord
implementations, it is a bunch of string and int properties.
QueryDescription
is a self-describing method of Query
returning a string.
DateFormating
returns a string from a DateTime
property.
The environement is not multithreaded, Query
is an abstract class, the shown GetRecordFromResults
is the override in an abstract child class (below that other child class are real implementations).