B
BSamp
I have the following business entity classes shown below. I have a data
layer that
retrieves the data from the database and populates a new instance of
the PendingRecord class then adds it to the PendingRecords collection.
i.e. PendingRecords pendingRecords = dataLayer.GetPendingRecords();
What I would like to do is to be able to have a method in the
collection
class that I could pass a wizardId and get the specific PendingRecord
instance based upon that specific wizardId.
such as: PendingRecord rec = pendingRecords.GetById(wizardId)
The current indexer in the
collection class returns the instance at the index of the collection,
but
not the instance for a particular wizardId.
How would I structure the method in the collection class to
accomplish this?
Or is there a better way?
I'm running Framework 1.1 on Visual Studio 2003
public class PendingRecord
{
#region Constructors
public PendingRecord() { }
public PendingRecord(int wizardId, string wizardType, string firstName,
string lastName)
{
_wizardId = wizardId;
_wizardType = wizardType;
_firstName = firstName;
_lastName = lastName;
}
#endregion
#region Properties
private int _wizardId = 0;
public int WizardId
{
get{ return _wizardId; }
set{ _wizardId = value; }
}
private string _wizardType = string.Empty;
public string WizardType
{
get{ return _wizardType; }
set{ _wizardType = value; }
}
private string _firstName = string.Empty;
public string FirstName
{
get{ return _firstName; }
set{ _firstName = value; }
}
private string _lastName = string.Empty;
public string LastName
{
get{ return _lastName; }
set{ _lastName = value; }
}
private string _confirmPage = string.Empty;
public string ConfirmationPage
{
get{ return _confirmPage; }
set{ _confirmPage = value; }
}
#endregion
}
public class PendingRecords : CollectionBase
{
public void Add(PendingRecord item)
{
InnerList.Add(item);
}
public void Remove(PendingRecord item)
{
InnerList.Remove(item);
}
public PendingRecord this[int index]
{
get { return (PendingRecord)InnerList[index]; }
set { InnerList[index] = value; }
}
}
layer that
retrieves the data from the database and populates a new instance of
the PendingRecord class then adds it to the PendingRecords collection.
i.e. PendingRecords pendingRecords = dataLayer.GetPendingRecords();
What I would like to do is to be able to have a method in the
collection
class that I could pass a wizardId and get the specific PendingRecord
instance based upon that specific wizardId.
such as: PendingRecord rec = pendingRecords.GetById(wizardId)
The current indexer in the
collection class returns the instance at the index of the collection,
but
not the instance for a particular wizardId.
How would I structure the method in the collection class to
accomplish this?
Or is there a better way?
I'm running Framework 1.1 on Visual Studio 2003
public class PendingRecord
{
#region Constructors
public PendingRecord() { }
public PendingRecord(int wizardId, string wizardType, string firstName,
string lastName)
{
_wizardId = wizardId;
_wizardType = wizardType;
_firstName = firstName;
_lastName = lastName;
}
#endregion
#region Properties
private int _wizardId = 0;
public int WizardId
{
get{ return _wizardId; }
set{ _wizardId = value; }
}
private string _wizardType = string.Empty;
public string WizardType
{
get{ return _wizardType; }
set{ _wizardType = value; }
}
private string _firstName = string.Empty;
public string FirstName
{
get{ return _firstName; }
set{ _firstName = value; }
}
private string _lastName = string.Empty;
public string LastName
{
get{ return _lastName; }
set{ _lastName = value; }
}
private string _confirmPage = string.Empty;
public string ConfirmationPage
{
get{ return _confirmPage; }
set{ _confirmPage = value; }
}
#endregion
}
public class PendingRecords : CollectionBase
{
public void Add(PendingRecord item)
{
InnerList.Add(item);
}
public void Remove(PendingRecord item)
{
InnerList.Remove(item);
}
public PendingRecord this[int index]
{
get { return (PendingRecord)InnerList[index]; }
set { InnerList[index] = value; }
}
}