public ErrorChargesRequest Select(string id, bool all = false) { using (var db = new BillingDbContext()) { if (all) { var sql1 = from o in db.ServiceRequests.OfType <ErrorChargesRequest>() .Include(o => o.RequestInfo) .Include(o => o.Routing).Include(o => o.Routing.Contracts) .Where(o => o.Id == id && o.State != EServiceRequestState.DELETED) select o; var req = sql1.SingleOrDefault(); if (req != null && req.Routing.Contracts.Count > 0) { foreach (var cwb in req.Routing.Contracts) { ContractWithBillings cwb1 = cwb; var sql2 = from c in db.Contracts.OfType <ContractWithBillings>().Include(c => c.Billings) where c.No == cwb1.No select c; cwb1 = sql2.SingleOrDefault(); } } return(req); } var sql = from o in db.ServiceRequests.OfType <ErrorChargesRequest>() .Include(o => o.RequestInfo) .Where(o => o.Id == id && o.State != EServiceRequestState.DELETED) select o; return(sql.SingleOrDefault()); } }
public List <ContractWithBillings> ToContracts(List <ContractWithBillingsDTO> list) { var os = new List <ContractWithBillings>(); foreach (var vo in list) { var o = new ContractWithBillings(); ClassCopier.Instance.Copy(vo, o); if (vo.Billings.Count > 0) { o.Billings = ToBillings(vo.Billings); } os.Add(o); } return(os); }