1
I am trying to create settings for a system. I thought of a class similar to the example:
Class:
public static class Configuracoes
{
[DisplayName("Casas Decimais")]
[Description("Informa o número de casas decimais que o sistema irá trabalhar")]
public static int CasasDecimais {get;set;}
[DisplayName("Opção A")]
[Description("Determina o Valor da opção A dentro do sistema")]
public static int OpcaoA {get;set;}
//...
public static int OpcaoX {get;set;}
//...
public static string OpcaoY {get;set;}
//...entre outras, apenas exemplo
}
Obviously, there will only be one configuration for the system. So I opted for the static class.
Now, to store this information, I would like to place a table with the following structure:
Table: Configurations
id | nome | descricao | valor
"CasasDecimais" | "Casas Decimais" | "Informa o número de casas ... trabalhar" | 2
...
Objective: (Example)
//...
decimal pagamento = x+y;
Console.WriteLine("O pagamento foi de: "+ pagamento.ToString("C"+Configuracoes.CasasDecimais);
Questions:
- It is possible to use this structure with the
entityframework 6
? If yes, how ? - Is it correct to use static class for this purpose ? Another more appropriate way to implement ?
Note: It is not a constant setting as Carlos suggested, and it is necessary to save it as it may be different for each client.
I have already made this configuration as an object, and each option as a column in the database. This way, the table has only one row. I don’t see a problem with that, I’m just trying to see if it’s possible to do it that way.
Thank you
Do you want to use this table in your Entity Framework settings equal to the class created by Carlos' answer? type when the Entity framework goes up it looks for this information in the table and sets up the Entity Framework?
– novic
@Virgilionovic does not... would be system settings on the client, for example, set up environment of issuing bills, url, decimals that would be displayed on the client screen...account plan for certain movements, etc... Entity only enters the time to save these settings to the bank
– Rovann Linhalis
"Entity only enters the time to save these settings in the database, "it must also enter the information recovery, so there must be your model to be used on the screens that need configuration. It cannot be a Static class in the Entity Framework, and also if it is web systems this Static class will be more disruptive than helping. Work with Entity Framework normally and recover these settings every time.
– novic
yes, missed the recovery part, the system is local, not web, as I had put, in the form of entity I’ve even done, the same doubt is whether it is possible to save class properties as rows and not as columns.
– Rovann Linhalis
Using a Dictionary? help ???
– novic
never used, I will search =]
– Rovann Linhalis
if it is Form you can use the Static class with Dictionary<string,string>
– novic