1

I have the following Linq, its linked to a report.

Resuming it's a report of bills, but bills have multiple products, so i have an ICollection of Products. The idea is to show each bill with their multiple Products in a single report using drilldown (trying to avoid subreports).

public class BillsDataSet
{
    public int IDGestion { get; set; }
    public string Comentario { get; set; }
    public ICollection<BillProduct> Products { get; set; }
    public decimal Monto { get; set; }
    public string Personal { get; set; }

    public static List<BillsDataSet> BillsPorFecha(DateTime dtFechaInicial, DateTime dtFechaFinal)
    {
        Context db = new Context();

        List<BillsDataSet> BillsDataSet = (from p in db.Bill
                                               select new BillsDataSet()
                                               {
                                                   IDGestion = p.IDBill,
                                                   Comentario = p.Historial.FirstOrDefault().Comentario,
                                                   Products = p.BillProduct,
                                                   Monto = p.Total,
                                                   Personal = p.Historial.FirstOrDefault().CodigoEmpleado
                                               }).ToList();
        return BillsDataSet;
    }
}

I'm getting this error on the web page report... I'm getting this error on the web page report

What I want to achieve is to have a drilldown on Products to hide/show all the Products related to the bill...

Luis
  • 5,786
  • 8
  • 43
  • 62

1 Answers1

0

Try the following

public static List<BillsDataSet> BillsPorFecha(DateTime dtFechaInicial, DateTime dtFechaFinal)
{
    Context db = new Context();

    List<BillsDataSet> BillsDataSet = (from p in db.Bill
                                           select new BillsDataSet()
                                           {
                                               IDGestion = p.IDBill,
                                               Comentario = p.Historial.FirstOrDefault().Comentario,
                                               Products = (from b in db.BillProduct where b.product_id == p.IDBill select new BillProduct()).ToList() as ICollection<BillProduct>,
                                               Monto = p.Total,
                                               Personal = p.Historial.FirstOrDefault().CodigoEmpleado
                                           }).ToList();
    return BillsDataSet;

}

chridam
  • 100,957
  • 23
  • 236
  • 235