Good Morning All,
I'm trying to use "Contains" to see if an object is within the collection. When I break I can see that the object is indeed part of the collection however "Contains" seems to be returning false indicating the item is not in the collection. Any idea what I'm doing wrong?
if(HttpContext.Current.Session["AutoPayTypes"] != null)
{
var autopays = HttpContext.Current.Session["AutoPayTypes"] as List<PaymentTypeInfo>;
char? coverageProductLine = null;
if(entityProps.ContainsKey("CoverageProductLine"))
{
coverageProductLine = (char?)entityProps["CoverageProductLine"];
}
var paymentTypeInfoRepository = new PaymentTypeInfoRepository();
var payType = paymentTypeInfoRepository.GetPaymentTypeInfo(paymentAdd.PayType,
coverageProductLine);
if (autopays != null && payType != null)
paymentAdd.DaysPaid = autopays.Contains(payType) ? null : paymentAdd.DaysPaid;
}
If the object is not in the collection the "DaysPaid" needs to be null. Any ideas?
***UPDATE PaymentTypeInfo is a standard LinqToSql generated class. Equals nor GetHashCode has been overridden at this point. Here is it's source.
[Table(Name="dbo.S_OptPaymentType")]
public partial class PaymentTypeInfo
{
private string _PaymentId;
private string _PaymentCode;
private System.Nullable<char> _CoverageType;
private string _ActionCode;
private System.Nullable<char> _PaymentType;
private string _BenAction;
private System.Nullable<char> _BenPremDisFlag;
private string _APNextToLastAct;
private string _APLastAct;
public PaymentTypeInfo()
{
}
[Column(Storage="_PaymentId", DbType="Char(3) NOT NULL", CanBeNull=false)]
public string PaymentId
{
get
{
return this._PaymentId;
}
set
{
if ((this._PaymentId != value))
{
this._PaymentId = value;
}
}
}
[Column(Storage="_PaymentCode", DbType="Char(2) NOT NULL", CanBeNull=false)]
public string PaymentCode
{
get
{
return this._PaymentCode;
}
set
{
if ((this._PaymentCode != value))
{
this._PaymentCode = value;
}
}
}
[Column(Storage="_CoverageType", DbType="Char(1)")]
public System.Nullable<char> CoverageType
{
get
{
return this._CoverageType;
}
set
{
if ((this._CoverageType != value))
{
this._CoverageType = value;
}
}
}
[Column(Storage="_ActionCode", DbType="VarChar(3)")]
public string ActionCode
{
get
{
return this._ActionCode;
}
set
{
if ((this._ActionCode != value))
{
this._ActionCode = value;
}
}
}
[Column(Name="PaymentType", Storage="_PaymentType", DbType="Char(1)")]
public System.Nullable<char> PaymentType
{
get
{
return this._PaymentType;
}
set
{
if ((this._PaymentType != value))
{
this._PaymentType = value;
}
}
}
[Column(Storage="_BenAction", DbType="VarChar(3)")]
public string BenAction
{
get
{
return this._BenAction;
}
set
{
if ((this._BenAction != value))
{
this._BenAction = value;
}
}
}
[Column(Storage="_BenPremDisFlag", DbType="Char(1)")]
public System.Nullable<char> BenPremDisFlag
{
get
{
return this._BenPremDisFlag;
}
set
{
if ((this._BenPremDisFlag != value))
{
this._BenPremDisFlag = value;
}
}
}
[Column(Storage="_APNextToLastAct", DbType="VarChar(3)")]
public string APNextToLastAct
{
get
{
return this._APNextToLastAct;
}
set
{
if ((this._APNextToLastAct != value))
{
this._APNextToLastAct = value;
}
}
}
[Column(Storage="_APLastAct", DbType="VarChar(3)")]
public string APLastAct
{
get
{
return this._APLastAct;
}
set
{
if ((this._APLastAct != value))
{
this._APLastAct = value;
}
}
}
}
Thanks, ~ck in San Diego