I need to create generic table field level cache.
Table primary key (PrimaryKeyStructType) can be int, string or struct
containing int and string fields.
FieldName contains table field name to be cached.
Remove() should remove table row from cache. Row is identified by table
primary key.
Trying compile class causes error
Operator '==' cannot be applied to operands of type
'PrimaryKeyStructType' and 'PrimaryKeyStructType'
How to fix this ?
Andrus.
using System.Collections.Generic;
class Cache<PrimaryKeyStructType{
struct Key {
public PrimaryKeyStructType PrimaryKey1Value;
public string FieldName;
}
Dictionary<Key, objectStore = new Dictionary<Key, object>();
/// <summary>
/// Removes table row from cache by removing all fields for this row
/// </summary>
/// <param name="id">Primary key value for row to be removed</param>
void Remove(PrimaryKeyStructType id) {
foreach (Key k in Store.Keys)
// Error 1 Operator '==' cannot be applied to operands of type
// 'PrimaryKeyStructType' and 'PrimaryKeyStructType'
if (k.PrimaryKey1Value == id)
Store.Remove(k);
}
}