Ejemplo n.º 1
0
    public virtual IQueryable <TEntity> Set <TEntity>()
        where TEntity : class
    {
        if (typeof(TEntity) == typeof(Animal))
        {
            return((IQueryable <TEntity>)Animals.AsQueryable());
        }

        if (typeof(TEntity) == typeof(AnimalQuery))
        {
            return((IQueryable <TEntity>)AnimalQueries.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Bird))
        {
            return((IQueryable <TEntity>)Animals.OfType <Bird>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(BirdQuery))
        {
            return((IQueryable <TEntity>)AnimalQueries.OfType <BirdQuery>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(Eagle))
        {
            return((IQueryable <TEntity>)Animals.OfType <Eagle>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(EagleQuery))
        {
            return((IQueryable <TEntity>)AnimalQueries.OfType <EagleQuery>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(Kiwi))
        {
            return((IQueryable <TEntity>)Animals.OfType <Kiwi>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(KiwiQuery))
        {
            return((IQueryable <TEntity>)AnimalQueries.OfType <KiwiQuery>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(Country))
        {
            return((IQueryable <TEntity>)Countries.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Drink))
        {
            return((IQueryable <TEntity>)Drinks.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Coke))
        {
            return((IQueryable <TEntity>)Drinks.OfType <Coke>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(Lilt))
        {
            return((IQueryable <TEntity>)Drinks.OfType <Lilt>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(Tea))
        {
            return((IQueryable <TEntity>)Drinks.OfType <Tea>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(Plant))
        {
            return((IQueryable <TEntity>)Plants.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Flower))
        {
            return((IQueryable <TEntity>)Plants.OfType <Flower>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(Daisy))
        {
            return((IQueryable <TEntity>)Plants.OfType <Daisy>().AsQueryable());
        }

        if (typeof(TEntity) == typeof(Rose))
        {
            return((IQueryable <TEntity>)Plants.OfType <Rose>().AsQueryable());
        }

        throw new InvalidOperationException("Invalid entity type: " + typeof(TEntity));
    }