报告VS 2010,深入了解ICollection

时间:2012-03-14 06:22:30

标签: c# visual-studio-2010 linq asp.net-mvc-3 reporting

我有以下Linq,它与报告相关联。

恢复它是一个账单报告,但账单有多个产品,所以我有ICollection Products。我们的想法是使用向下钻取(试图避免子报告)在单个报告中显示每个帐单及其多个Products

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

我想要实现的是在Products上进行深入分析,以隐藏/显示与该法案相关的所有Products ...

1 个答案:

答案 0 :(得分:0)

尝试以下

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;

}