Cannot implicitly Convert type list to an Object

Asked

Viewed 601 times

0

Good night,

I’m doubting the following mistake:

Cannot implicitly Convert type 'System.Collections.Generic.List' to 'ITCore.FlowCredit.Business.Entities.ProdutoAmortizacaoCreditoDiasSearch'

The Code:

private void LoadDia()
    {
        ProdutoAmortizacaoCreditoDiasSearch pont = new ProdutoAmortizacaoCreditoDiasSearch();

        ProdutoAmortizacaoCreditoDias aDay = new ProdutoAmortizacaoCreditoDias();

        int? id_TipoDia = txtDay.Text.ToInt32Nullable();
        DateTime? DiaInicio = dtCreationFrom.Text.ToDateTimeNullable();
        DateTime? DiaFim = dtCreationFrom.Text2.ToDateTimeNullable();
        string id_Produto = txtProduto.Text;

        try
        {
            pont = FlowCreditTaxasProdutoExtensaoPrazoProviderManager.Provider.GetTodosDiasAmortizacaoCredito(id_TipoDia, id_Produto);
            if (pont != null)
            {
                BindGridProducts(pont);
            }
        }
        catch (Exception ex)
        {
            ExceptionHelper.ShowError(ex, false);
        }

    }

The mistake is in:

pont =  FlowCreditTaxasProdutoExtensaoPrazoProviderManager.Provider.GetTodosDiasAmortizacaoCredito(id_TipoDia, id_Produto);

This is the role of the President:

#region Gets

public override List<ProdutoAmortizacaoCreditoDias> GetTodosDiasAmortizacaoCredito(int? id_TipoDia, String id_Produto)
{
    List<ProdutoAmortizacaoCreditoDias> ProdutoAmortizacaoCreditoDiasObj = new List<ProdutoAmortizacaoCreditoDias>();

    try
    {
        ProdutoAmortizacaoCreditoDiasObj = ProdutoAmortizacaoDiasUtils.GetTodosProdutoAmortizacaoDias(id_TipoDia, id_Produto).result;
    }
    catch (Exception ex)
    {
        CoreLog.LogError(ex);
        throw new CoreException(ex.Message);
    }
    return ProdutoAmortizacaoCreditoDiasObj;
}

And here is the commonProviders:

public abstract List<ProdutosConfiguracaoTaxas> GetTodosProdutosConfiguracaoTaxas(DateTime? id_DataAtiva, String id_Produtos);

[DataContract, Serializable]
public class ProdutoAmortizacaoCreditoDiasSearch
{
    [DataMember]
    public List<ProdutoAmortizacaoCreditoDias> result { get; set; }

    [DataMember]
    public decimal NumberRecords { get; set; }

    [DataMember]
    public int ReturnValue { get; set; }
}
  • I could elaborate on your question, I’m not sure I understand.

  • It’s solved! Thank you

  • 2

    Look, try not to take this the wrong way, but I have no idea how you’re "programming" without understanding something extremely basic like this. Try to study the language, do exercises basic, these things. The beginning is always the best starting point. It is no use trying to start writing something great. I see this looks like some commercial application and I have no idea what’s going on, but I wanted to give you a hint. (I was writing an answer to explain to you what happens and I removed this thingy from her).

  • I appreciate the help jbueno! I am working as a programmer, but my area is Java and they put me in a project in the ASP.NET banking and I am still learning how it works

1 answer

1


The error is happening because it fails to convert the list of ... Days you return to the object ... Diassearch.

Updated

Replace the wrong line with:

 pont.result = FlowCreditTaxasProdutoExtensaoPrazoProviderManager.Provider.‌​GetTodosDiasAmortiza‌​caoCredito(id_TipoDi‌​a, id_Produto);
  • What I was told was to put a list<> to call the method. but how can I do that? I don’t understand. So I have to convert the list to an object, right? The problem is I don’t get there :S

  • You can place the properties of objects?

  • I put in doubt another part of the code!

  • You need to put Pont.result = Flowcredittaxaspextensionproductaoprazoprovidermanager.Provider.Gettodosdiasamortizacaocredito(id_TipoDia, id_Product);

  • Thank you Lucas! It’s always good to learn from someone who knows :D Thank you again!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.