Reputation: 2384
I have this database model where I have one column holding a score, which in this case is a summuraized value of all the score give to an item over the past x months..anyway.. and I also have another column which holds the number of votes that has been done dureing the same x months as the score... (the score can be give by a user in the values of 1-10)
I now need to get the score/votes value.. and I would like to create a new property for my entity-model that holds the value of score/votes.. how would I do this?.. I have tried by simply creating a Scalar Property, but I just cant get it to work.. can anyone point me in the right direction?
Thanks in advance!
Upvotes: 0
Views: 194
Reputation: 10248
You could use a partial class:
public partial class MyEntity
{
public double MyComputedValue
{
get
{
return this.Score/this.Value;
}
}
}
This allows you to add functionality to an Entity - the partial class name should match your entity name (which is also declared as a partial class) when you use it you will see that both partial class properties are available in the logical class. This could be compared (in a fashion) to a Join on two tables in a database that create one logical structure.
Upvotes: 3