I Have this method:
public IEnumerable<PackModel> PackLookup(short? society, string description)
{
return this.context.Pack.Where(x => x.Description.Contains(description) &&
(!society.HasValue || x.Society == society))
.OrderBy(x => x.Code)
.Take(this.max);
}
public IEnumerable<FeaturesModel> FeaturesLookup(short? society, string description)
{
return this.context.Features.Where(x => x.Description.Contains(description) &&
(!society.HasValue || x.Society == society))
.OrderBy(x => x.Code)
.Take(this.max);
}
public IEnumerable<ConstraintsModel> ConstraintsLookup(short? society, string description)
{
return this.context.Constraints.Where(x => x.Description.Contains(description) &&
(!society.HasValue || x.Society == society))
.OrderBy(x => x.Code)
.Take(this.max);
}
The three methods are very similar, only the DbSet changes, how could I make these calls in a generic way to avoid code duplication