public static DbSet <TModel> GetDataStorage <TModel>(MinibusContext context) where TModel : class { var cType = context.GetType(); var mType = typeof(DbSet <TModel>); var dsProperty = cType.GetProperties().FirstOrDefault(property => property.PropertyType == mType); if (dsProperty == null) { throw new ObjectNotFoundException(string.Format("Data storage for model {0} is not found", mType.FullName)); } return((DbSet <TModel>)dsProperty.GetValue(context)); }
public Repository() { _context = new MinibusContext(); _dataStorage = MinibusContext.GetDataStorage <TModel>(_context); }