public Billing[] getBilling(GetBillingRequest request)
    {
        DetachedCriteria criteria = DetachedCriteria.For<Bill>();

        if (request.orderby != null)
        {
            RequestOrderByHelper.ConverToCriteria(request.orderby, orderbyFiledsMapping, criteria);
        }

        IList<Bill> billList = TheCriteriaMgr.FindAll<Bill>(criteria, request.beginRowIndex, request.beginRowIndex + request.rowSize);
        List<Billing> billingList = new List<Billing>();

        foreach (Bill bill in billList)
        {
            Billing billing = fillBill(bill);
            foreach (BillDetail billDetail in bill.BillDetails)
            {
                BillingItem billingItem = fillBillDetail(billDetail);
                billing.AddBillingItem(billingItem);
            }
            billingList.Add(billing);
        }

        return billingList.ToArray();
    }
    public int getBillingCount(GetBillingRequest request)
    {
        DetachedCriteria criteria = DetachedCriteria.For<Bill>().SetProjection(Projections.ProjectionList()
               .Add(Projections.Count("OrderNo")));
        IList list = TheCriteriaMgr.FindAll(criteria, request.beginRowIndex, request.beginRowIndex + request.rowSize);

        int count = 0;
        if (list != null && list.Count > 0)
        {
            if (list[0] is int)
            {
                count = int.Parse(list[0].ToString());
            }
        }
        return count;
    }