예제 #1
0
    public IQueryable <TEntity> Set <TEntity>()
        where TEntity : class
    {
        if (typeof(TEntity) == typeof(Customer))
        {
            return((IQueryable <TEntity>)Customers.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Employee))
        {
            return((IQueryable <TEntity>)Employees.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Order))
        {
            return((IQueryable <TEntity>)Orders.AsQueryable());
        }

        if (typeof(TEntity) == typeof(OrderDetail))
        {
            return((IQueryable <TEntity>)OrderDetails.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Product))
        {
            return((IQueryable <TEntity>)Products.AsQueryable());
        }

        if (typeof(TEntity) == typeof(CustomerQuery))
        {
            return((IQueryable <TEntity>)CustomerQueries.AsQueryable());
        }

        if (typeof(TEntity) == typeof(OrderQuery))
        {
            return((IQueryable <TEntity>)OrderQueries.AsQueryable());
        }

        if (typeof(TEntity) == typeof(ProductQuery))
        {
            return((IQueryable <TEntity>)ProductQueries.AsQueryable());
        }

        if (typeof(TEntity) == typeof(ProductView))
        {
            return((IQueryable <TEntity>)ProductViews.AsQueryable());
        }

        if (typeof(TEntity) == typeof(CustomerQueryWithQueryFilter))
        {
            return((IQueryable <TEntity>)CustomerQueriesWithQueryFilter.AsQueryable());
        }

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