-1
For reasons of errors with a Windows version I ended up not working with databases and started using files JSON
. But I need to upload only part of the items (List) to one DataGridView
according to the "type" I select in a ComboBox
. For this I am using the conditional loop switch
:
public class LotofacilQuantidades
{
public int CONC { get; set; }
public string DATA { get; set; }
public int SOMA { get; set; }
public int qPAR { get; set; }
public string PAR { get; set; }
public int qIMP { get; set; }
public string IMPAR { get; set; }
public int qREP { get; set; }
public string REPETIDO { get; set; }
public string INICIAL { get; set; }
public string FINAL { get; set; }
public int qFIB { get; set; }
public string FIBONACCI { get; set; }
public int qNP { get; set; }
public string PRIMOS { get; set; }
public int qINP { get; set; }
public string INP { get; set; }
public int qMD { get; set; }
public string MOLDURA { get; set; }
public int qSQ { get; set; }
public string SEQUENCIA { get; set; }
public int qITV { get; set; }
public string INTERVALO { get; set; }
public int qX { get; set; }
public string XIS { get; set; }
public int qL01 { get; set; }
public string LINHA_01 { get; set; }
public int qL02 { get; set; }
public string LINHA_02 { get; set; }
public int qL03 { get; set; }
public string LINHA_03 { get; set; }
public int qL04 { get; set; }
public string LINHA_04 { get; set; }
public int qL05 { get; set; }
public string LINHA_05 { get; set; }
public int qC01 { get; set; }
public string COLUNA_01 { get; set; }
public int qC02 { get; set; }
public string COLUNA_02 { get; set; }
public int qC03 { get; set; }
public string COLUNA_03 { get; set; }
public int qC04 { get; set; }
public string COLUNA_04 { get; set; }
public int qC05 { get; set; }
public string COLUNA_05 { get; set; }
}
What I need is to deserialize the file JSON
taking only the "CONC", "DATA" + the type that was determined in the ComboBox
and its corresponding amount. Ex: case : "ODD" it would bring me the list with "CONC", "DATA", "ODD", "qIMP".
Something like:
//busco o arquivo json
var _arq = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Relatorio.json");
//listo o arquivo
List<LotofacilQuantidades> _lstFinal = JsonConvert.DeserializeObject<List<LotofacilQuantidades>>(_arq);
//seleciono os itens que pretendo utilizar com o switch/case (aqui está meu erro/problema)
var teste1 = _lstFinal.Select(c => c.CONC && c.DATA && c.FINAL).ToList();
In this case it is only allowed to list an item with Select.
1- the OS is not a forum. 2- go to [Tour] to understand 3- just vc do an if and return the select according to the condition q vc need... and do not need to read the json file every time... the select should be...
.Select(c => new { c.CONC, c.DATA, c.Final });
– Rovann Linhalis
OK Rovann. Thank you so much for your help.
– pSouza73