Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- есть запрос на Entity Framework который вызывает таблицы из БД по Id другой таблицы
- var result = this.Context.LiveEnquiryServices
- .Include("LiveService")
- .Include("LiveEnquirySection")
- .Include("LiveEnquiryDocuments")
- .FirstOrDefault(x => x.LiveEnquirySectionId == liveEnquirySectionId && x.LiveServiceId == serviceId);
- return result;
- public List<LiveEnquiryService> GetLiveEnquiryServices(Enquiry enquiry)
- {
- List<LiveEnquiryService> liveEnquiryService = new List<LiveEnquiryService>();
- var query = $"SELECT LiveService.*, LiveEnquirySection.*, LiveEnquiryDocuments.* FROM LiveEnquiryServices WHERE LiveEnquirySectionId = '{enquiry.Id}';";
- using (IDbConnection db = new SqlConnection(_connectionString))
- {
- liveEnquiryService = db.Query<LiveEnquiryService, LiveService, LiveEnquirySection, List<LiveEnquiryServiceDocument>, LiveEnquiryService>(query, (les, ls, lesn, lesd) =>
- {
- les.LiveService = ls;
- les.LiveServiceId = ls.Id;
- les.LiveEnquirySection = lesn;
- les.LiveEnquirySectionId = lesn.Id;
- les.LiveEnquiryDocuments = lesd;
- //les.LiveEnquiryDocuments = lesd;
- return les;
- }, splitOn: "Id").ToList();
- }
- return liveEnquiryService.ToList();
- }
Add Comment
Please, Sign In to add comment