ScientificReport
PatentLicenseActivityRepository.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using Microsoft.EntityFrameworkCore;
8 
9 namespace ScientificReport.DAL.Repositories
10 {
11  public class PatentLicenseActivityRepository: IRepository<PatentLicenseActivity>
12  {
13  private readonly ScientificReportDbContext _context;
14 
16  {
17  _context = context;
18  }
19 
20  public virtual IEnumerable<PatentLicenseActivity> All()
21  {
22  return _context.PatentLicenseActivities
23  .Include(b => b.AuthorsPatentLicenseActivities)
24  .ThenInclude(b => b.Author)
25  .Include(b => b.CoauthorsPatentLicenseActivities)
26  .Include(a=>a.ApplicantsPatentLicenseActivities)
27  .ThenInclude(b => b.Applicant)
28  .Include(b => b.CoApplicantsPatentLicenseActivities);
29  }
30 
31  public virtual IEnumerable<PatentLicenseActivity> AllWhere(Func<PatentLicenseActivity, bool> predicate)
32  {
33  return All().Where(predicate);
34  }
35 
36  public virtual PatentLicenseActivity Get(Guid id)
37  {
38  return All().FirstOrDefault(u => u.Id == id);
39  }
40 
41  public virtual PatentLicenseActivity Get(Func<PatentLicenseActivity, bool> predicate)
42  {
43  return All().Where(predicate).FirstOrDefault();
44  }
45 
46  public virtual void Create(PatentLicenseActivity item)
47  {
48  _context.PatentLicenseActivities.Add(item);
49  _context.SaveChanges();
50  }
51 
52  public virtual void Update(PatentLicenseActivity item)
53  {
54  if (item != null)
55  {
56  _context.PatentLicenseActivities.Update(item);
57  _context.SaveChanges();
58  }
59  }
60 
61  public virtual void Delete(Guid id)
62  {
63  var item = _context.PatentLicenseActivities.Find(id);
64  if (item != null)
65  {
66  _context.PatentLicenseActivities.Remove(item);
67  _context.SaveChanges();
68  }
69  }
70 
71  public virtual IQueryable<PatentLicenseActivity> GetQuery()
72  {
73  return _context.PatentLicenseActivities;
74  }
75  }
76 }
virtual IEnumerable< PatentLicenseActivity > AllWhere(Func< PatentLicenseActivity, bool > predicate)
virtual PatentLicenseActivity Get(Func< PatentLicenseActivity, bool > predicate)