Exemplo n.º 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));
    }
Exemplo n.º 2
0
        public IEnumerable <Order> GetOrders(int?id, String name, OrderStatus?status)
        {
            if (id == null && name == null && status == null)
            {
                return(Orders);
            }

            if (id != null)
            {
                return(Orders.AsQueryable().Where(o => o.Id == id));
            }

            if (name != null)
            {
                return(Orders.AsQueryable().Where(o => o.Name.Contains(name)));
            }

            if (status != null)
            {
                return(Orders.AsQueryable().Where(o => o.Status == status));
            }

            return(Enumerable.Empty <Order>());
        }
Exemplo n.º 3
0
 public IEnumerable <Order> TableFunctionWithParameters(int?id, String name, OrderStatus?status) => Orders.AsQueryable().Where(o => (o.Id == id) || EF.Functions.Like(o.Name, "%" + name + "%") || (o.Status == status));
Exemplo n.º 4
0
 public int ScalarFunctionWithParameters(int?id, String name, OrderStatus?status) => Orders.AsQueryable().Where(o => o.Id == id || o.Name.Contains(name) || o.Status == status).Count();