I wonder how you approach this problem.
I have two taxes that may apply to my products. I specifically want to avoid storing Taxrates in the database, but still I can change them in a central place (for example, Taxrate from 20% to 19%, etc.).
so I decided that it would be great if they just compiled into my application (it’s internal). The problem is that I want to not only know the tariff, but also the name of the tax rate.
I could go with Enum, which displays the value. But then I will have to create some method that extracts the German name of this Taxrate for the English value enum (I write my code in English, the application is in German).
I thought about just using hard-coded objects to reflect this,
public interface Taxrate { string Name { get; } decimal Rate { get; } } public class NormalTaxRate : Taxrate { public string Name { get { return "Regelsteuersatz"; } } public decimal Rate { get { return 20m; } } }
But then I will have to create some kind of list containing two instances of these two objects. Performing this static action may work, but still I will need to save some list. I also need to find a way to map my POCO domain object to this, because I doubt that NHibernate can create an instance of the desired object depending on the value in the field.
This is really not the case, and I think something is missing here. Hope someone has a better solution, I can’t think about it.
Greetings Daniel
Ps: also, please repeat this question, if you find something suitable, I can’t think of more meaningful tags right now.
source share