private ReportDataSource GetLoan(DateTime?dateFrom, DateTime?dateTo, string partnerId) { IEnumerable <TLoan> loans = _loanRepository.GetListByAccDatePartner(dateFrom, dateTo, partnerId); var list = from loan in loans select new { loan.Id, CustomerName = loan.PersonId.PersonName, PartnerId = loan.PartnerId != null ? loan.PartnerId.Id : null, PartnerName = loan.PartnerId != null ? loan.PartnerId.PartnerName : null, Address = loan.AddressId != null ? loan.AddressId.Address : null, SalesmanName = loan.SalesmanId != null ? loan.SalesmanId.PersonId.PersonName : null, SalesmanId = loan.SalesmanId != null ? loan.SalesmanId.Id : null, loan.LoanNo, loan.LoanCode, loan.LoanAccDate, loan.LoanSubmissionDate, loan.LoanBasicPrice, loan.LoanCreditPrice, loan.LoanStatus } ; ReportDataSource reportDataSource = new ReportDataSource("LoanViewModel", list.ToList()); return(reportDataSource); }