using CAPI.Custom.Entities; using System.Linq; namespace CAPI.Custom.Data.Repositories { public class SurfaceChildItemRepository : SurfaceEntityRepository where TSurfaceChildItem : class, ISurfaceChildEntity { public SurfaceChildItemRepository() { } public SurfaceChildItemRepository(QuotesContext dbContext) { this.db = dbContext ?? QuotesContext.Create(); } public virtual IQueryable GetByParentId(int parentId) => db.Set().Where(p => p.ParentSurfaceItemId == parentId); public virtual TParentSurfaceItem GetParent(TSurfaceChildItem childItem) where TParentSurfaceItem : class, ISurfaceEntity { return db.Set().FirstOrDefault(p => p.itemID == childItem.ParentSurfaceItemId); } } }