0
I am trying to generate a report with Reportviewer about the items of a sale, the report is displayed but in the product column instead of appearing the product appears #Erro
. My classes are all with [Serializable]
but still not working and returns the Warning: Warning: A expressão Value para textrun ‘produto.Paragraphs[0].TextRuns[0]’ contém um erro: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (rsRuntimeErrorInExpression)
.
The strange thing is that if I give one foreach
in the list before generating the report the information is displayed in the Console
and tbm in Reportviewer correctly. But passing the list directly without the foreach
doesn’t work.
How to solve this problem ?
Generating report.
private void geraRelContasReceberDetalhado() {
foreach (ItemVenda iv in this.listaItens) {
Console.WriteLine("produto: " + iv.produto.descricao);
}
reportViewer.Reset();
reportViewer.LocalReport.ReportPath = @"..\..\reports\RelContasReceberDetalhado.rdlc";
ReportDataSource rds = new ReportDataSource("DataSetRelContasReceberDetalhado", this.listaItens);
//List<ReportParameter> listParams = new List<ReportParameter>();
// rv.LocalReport.SetParameters(listParams);
reportViewer.LocalReport.DataSources.Add(rds);
}
Classes
//ItemVenda
[Serializable]
public class ItemVenda {
public virtual long id { set; get; }
public virtual Venda venda { set; get; }
public virtual Produto produto { set; get; }
public virtual decimal valorUn { set; get; }
public virtual int quantidade { set; get; }
public virtual decimal total { set; get; }
public ItemVenda() {
}
}
[Serializable]
public class Produto {
public virtual long id { set; get; }
public virtual string descricao { set; get; }
public virtual CategoriaProduto categoriaProduto { set; get; }
public virtual UnidadeProduto unidadeProduto { set; get; }
public virtual decimal valorCusto { set; get; }
public virtual decimal valorVenda { set; get; }
public virtual int qtdEstoque { set; get; }
public virtual int estoqueMin { set; get; }
public virtual int estoqueMax { set; get; }
public virtual int status { set; get; }
public virtual string imagem { set; get; }
public Produto() {
}
public override string ToString() {
return descricao;
}
}
Print of the report.
This list comes from the ORM Entity Framework?
– novic
@Virgilionovic I’m using Nhibernate with Fluentnhibernate.
– FernandoPaiva
Make a check and bring those formatted items gets better or make a query with Join.
– novic
@Virgilionovic I will try !
– FernandoPaiva
You did it @Fernandopaiva?
– novic
@Virgilionovic no, so I kept the foreach before invoking the report and so a gambiarra that works.
– FernandoPaiva
put in the question where the variable results this.listItens. I’ll see and answer you.
– novic
@Virgilionovic she is a
IList<ItemVenda>
which I pass as Dataset for the report. The weirdest thing is how I said, if I pass it without doing theforeach
before it does not display the description of the product that is in its mapping. I have other reports that step tbm aIList
like Dataset and I don’t have this problem, only in this item list that gave it. And all my classes are with[Serializable]
so I have no idea what it might be. Thank you.– FernandoPaiva
Okay, put the lines that carry this list
– novic