You're using DataReader to perform the select. This is great for efficiency as DataReader is a linear, readonly, forward only process. The drawback is that you can't tell if duplicate records exist until you look at the results.
So. Two ways:
One: Compare the given result with what has already been found:
(I have no idea what CustomDataCollectionQuestionDtoList is so I'll guess that it's the auto generated return type of the stored procedure)
using (IDataReader dataReader = db.ExecuteReader(selectCommand))
{
while (dataReader.Read())
{
var next = ParseDto<customdatacollectionquestiondto>(dataReader);
if(!questionList.DtoList.Any(item=>item.a==next.a&&item.b==next.b)
questionList.DtoList.Add(ParseDto<customdatacollectionquestiondto>(dataReader));
}
customDataCollectionDto.CustomDataCollectionQuestionList = questionList;
}
</customdatacollectionquestiondto></customdatacollectionquestiondto>
This is pretty good for small result sets but gets to be a real issue for larger sets.
The other method is to use the build in functionality of the completed set.
(again: no idea what CustomDataCollectionQuestionDtoList is so the available methods may differ)
using (IDataReader dataReader = db.ExecuteReader(selectCommand))
{
while (dataReader.Read())
{
var next = ParseDto<customdatacollectionquestiondto>(dataReader);
if(!questionList.DtoList.Any(item=>item.a==next.a&&item.b==next.b)
questionList.DtoList.Add(ParseDto<customdatacollectionquestiondto>(dataReader));
}
customDataCollectionDto.CustomDataCollectionQuestionList = questionList.Distinct();
}
</customdatacollectionquestiondto></customdatacollectionquestiondto>
This works great for Linq objects (hopefully CustomDataCollectionQuestionDtoList is at least an IEnumerable) but is most of your results are duplicates you have to be aware that questionList is going to be a lot larger than is needs to be.
Weigh up the options depending on your result set size and the percent of duplicates.
Hope that helps
have fun ^_^