T
tshad
I want to search on multiple properties in a list to find the correct list
item. I tried using an Icomparer which I use for sorting but not sure how
to call it (if it would even work).
Anyone know how I would change this to work?
***********************************
public class PropertyForeignKey : ForeignKey
{
#region PropertyForeignekey Members
private int propertyType;
private int propertyOrder;
public PropertyForeignKey(string tableName, string foreignKeyName,
decimal foreignKeyValue,
int propertyType,int propertyOrder) : base
(tableName,foreignKeyName,foreignKeyValue)
{
this.propertyType = propertyType;
this.propertyOrder = propertyOrder;
}
public int PropertyType
{
get { return this.propertyType; }
set { this.propertyType = (int)value; }
}
public int PropertyOrder
{
get { return this.propertyOrder; }
set { this.propertyOrder = (int)value; }
}
new public string ToString()
{
return TableName + " / " + ForeignKeyName + " / " +
ForeignKeyValue + " / " + PropertyType + " / " + PropertyOrder;
}
#endregion
}
public class PropertyForeignKeyCollection : List<PropertyForeignKey> { }
public class PropertyForeignKeyComparer : IComparer<PropertyForeignKey>
{
public int Compare(PropertyForeignKey firstInstance,
PropertyForeignKey secondInstance)
{
int result = 0;
result =
firstInstance.TableName.CompareTo(secondInstance.TableName);
if (result != 0) return (result); // if not equal, not need to
check Name
result =
secondInstance.ForeignKeyName.CompareTo(secondInstance.ForeignKeyName);
if (result != 0) return (result);
result =
secondInstance.PropertyType.CompareTo(secondInstance.PropertyType);
if (result != 0) return (result);
result =
secondInstance.PropertyOrder.CompareTo(secondInstance.PropertyOrder);
if (result != 0) return (result);
return result;
}
}
***********************************
Thanks,
Tom
item. I tried using an Icomparer which I use for sorting but not sure how
to call it (if it would even work).
Anyone know how I would change this to work?
***********************************
public class PropertyForeignKey : ForeignKey
{
#region PropertyForeignekey Members
private int propertyType;
private int propertyOrder;
public PropertyForeignKey(string tableName, string foreignKeyName,
decimal foreignKeyValue,
int propertyType,int propertyOrder) : base
(tableName,foreignKeyName,foreignKeyValue)
{
this.propertyType = propertyType;
this.propertyOrder = propertyOrder;
}
public int PropertyType
{
get { return this.propertyType; }
set { this.propertyType = (int)value; }
}
public int PropertyOrder
{
get { return this.propertyOrder; }
set { this.propertyOrder = (int)value; }
}
new public string ToString()
{
return TableName + " / " + ForeignKeyName + " / " +
ForeignKeyValue + " / " + PropertyType + " / " + PropertyOrder;
}
#endregion
}
public class PropertyForeignKeyCollection : List<PropertyForeignKey> { }
public class PropertyForeignKeyComparer : IComparer<PropertyForeignKey>
{
public int Compare(PropertyForeignKey firstInstance,
PropertyForeignKey secondInstance)
{
int result = 0;
result =
firstInstance.TableName.CompareTo(secondInstance.TableName);
if (result != 0) return (result); // if not equal, not need to
check Name
result =
secondInstance.ForeignKeyName.CompareTo(secondInstance.ForeignKeyName);
if (result != 0) return (result);
result =
secondInstance.PropertyType.CompareTo(secondInstance.PropertyType);
if (result != 0) return (result);
result =
secondInstance.PropertyOrder.CompareTo(secondInstance.PropertyOrder);
if (result != 0) return (result);
return result;
}
}
***********************************
Thanks,
Tom