public IQueryable <TEntity> Set <TEntity>() where TEntity : class { if (typeof(TEntity) == typeof(NullSemanticsEntity1)) { return((IQueryable <TEntity>)Entities1.AsQueryable()); } if (typeof(TEntity) == typeof(NullSemanticsEntity2)) { return((IQueryable <TEntity>)Entities2.AsQueryable()); } throw new InvalidOperationException("Invalid entity type: " + typeof(TEntity)); }