Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
How to get all the females?

I would like to get the gender for calculations, for example the male and female options are in one column. I would like to get all male or all female for calculation.

I have a "computed property" which gives me list of all the items along with calculation. Here is the code:

partial void MeanFemale_Compute(ref string result)
{
    // Set result to the desired field value

    int totalAge = 0;
    int count = 0;

    foreach (InsuranceQuotation i in his.DataWorkspace.ApplicationData.InsuranceQuotations)
    {
        totalAge += i.mAge;
        count++;
    }

    if (count != 0)
    {
        result = (totalAge / count).ToString();
    }

}

How do I get to filter the gender in this "computed property".

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You can use LINQ. It would look something like this:

int averageAge =  this.DataWorkspace.ApplicationData.InsuranceQuotations.
    Where(iq => iq.Gender == Gender.Female).
    Average(iq => iq.mAge);
over 4 years ago · Santiago Trujillo Relatório

0

Could you filter with an if statement?

partial void MeanFemale_Compute(ref string result)
{
    // Set result to the desired field value

    int totalAge = 0;
    int count = 0;

    foreach (InsuranceQuotation i in this.DataWorkspace.ApplicationData.InsuranceQuotations)
    {

        if(i.Female == true)
        {
            totalAge += i.mAge;
            count++;
        }
    }

    if (count != 0)
    {
        result = (totalAge / count).ToString();
    }

}
over 4 years ago · Santiago Trujillo Relatório

0

Hope this would help someone else for filtering the Choice List in _InitializeDataWorkspace:

        // get count of females
        double fgender = (from gender in InsuranceQuotations
                             where gender.mGender == "Female"
                             select gender).Count();

        //get sum of females ages
        double female = InsuranceQuotations.Where(x => x.mGender == "Female").Sum(t => t.mAge);

        // get count males
        double mgender = (from gender in InsuranceQuotations
                             where gender.mGender == "Male"
                             select gender).Count();

        //get sum of males ages
        double male = InsuranceQuotations.Where(x => x.mGender == "Male").Sum(t => t.mAge);     

        // MeanFmale amd MeanMmale - The fields that display 
        MeanFmale = (female / fgender).ToString();
        MeanMmale = (male / mgender).ToString();

Or

   double fmale = InsuranceQuotations.Where(x => x.mGender == "Female").Average(t => t.mAge);

   double mmale = InsuranceQuotations.Where(x => x.mGender == "Male").Average(t => t.mAge);

    // MeanFmale amd MeanMmale - The fields that display 
    MeanFmale = fmale.ToString();
    MeanMmale = mmale.ToString();
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda