I have to following classes:
public class NominalValue
{
public int Id {get; set;}
public string ElementName {get; set;}
public decimal From {get; set;}
public decimal To {get; set;}
public bool Enable {get; set;}
public DateTime CreationDate {get; set;}
public int StandardValueId {get; set;} //FK for StandardValue
}
public class StandardValue
{
public int Id {get; set;}
public string ElementName {get; set;}
public decimal From {get; set;}
public decimal To {get; set;}
public bool Enable {get; set;}
public DateTime CreationDate {get; set;}
}
User wants to fill nominalValue
object properties. filling the nominalValue
properties can performed in 2 way:
- User fill values for
nominalValue
manually. - User Load values for
nominalValue
from astandardValue
object and then change some values or not.
sometimes I need to know if some property of nominalValue
objects for a specified Element are equal to corresponding standardValue
or not?
I don't want to load standardValue
from Db
for checking this equality, so I decided to define a HashValue
property in NominalValue
class:
public class NominalValue
{
public int Id {get; set;}
public string ElementName {get; set;}
public decimal From {get; set;} //<-- 1st parameter for generating hash value
public decimal To {get; set;} //<-- 2nd parameter for generating hash value
public bool Enable {get; set;} //<-- 3rd parameter for generating hash value
public DateTime CreationDate {get; set;}
public int StandardValueId {get; set;}
public string HashValue {get;set;} //<-- this property added
}
when user fill nominalValue
properties using standardValue
properties, I calculate its value based on 3 properties(From
, To
, Enable
) and save it with other properties, and when I check if that nominalValue
fill with standardValue
or not, I calculate hash code for From
, To
, Enable
and compare the result with HashValue
(instead loading standardValue
from Db
).
Is there any mechanism to calculate a unique hash code based on 3 property values(From
, To
, Enable
)?