Is the method that I am using for retrieval in my generic list optimized
Posted
by fishhead
on Stack Overflow
See other posts from Stack Overflow
or by fishhead
Published on 2010-06-06T22:16:13Z
Indexed on
2010/06/06
22:22 UTC
Read the original article
Hit count: 157
c#
At some time there will be a large amount of records, about 50,000. with that in mind is the method GetEquipmentRecord up to the task. thanks for you opinions.
public enum EquipShift { day, night };
public class EquipStatusList : List<EquipStatus>
{
string SerialFormat = "yyyyMMdd";
int _EquipmentID;
string _DateSerial;
EquipShift _Shift;
public EquipStatus GetEquipmentRecord(int equipmentID, EquipShift shift,
DateTime date)
{
_DateSerial = date.ToString(SerialFormat);
_Shift = shift;
_EquipmentID = equipmentID;
return this.Find(checkforEquipRecord);
}
bool checkforEquipRecord(EquipStatus equip)
{
if ((equip.EquipmentID == _EquipmentID)
&& (equip.Shift == _Shift)
&& (equip.Date.ToString(SerialFormat) == _DateSerial))
return true;
else
return false;
}
}
© Stack Overflow or respective owner