예제 #1
0
        public CustomerSearchModel FindById(int customerId)
        {
            var result = _context.Customers.Where(c => c.CustomerId == customerId);

            result = (IQueryable <Customer>)ExpandOperator.ExpandRelatedEntities <Customer>(result);

            var customer       = result.FirstOrDefault();
            var customerSearch = CustomerOperator.SetCustomerSearchModelCascade(customer);

            return(customerSearch);
        }
예제 #2
0
        public async Task <CustomerSubSearchModel> GetCustomerByProjectIdAsync(int projectId)
        {
            var project = await _context.Projects.Include(p => p.Customer)
                          .Where(p => p.ProjectId == projectId).FirstOrDefaultAsync();

            var customer = project == null ? null : project.Customer;

            var customerSearch = CustomerOperator.SetCustomerSubSearchModel(customer);

            return(customerSearch);
        }
예제 #3
0
        public IEnumerable <CustomerSearchModel> GetAll()
        {
            var queryData = from C in _context.Customers
                            select C;

            var result = QueryOperate <Customer> .Execute(queryData);

            result = (IQueryable <Customer>)ExpandOperator.ExpandRelatedEntities <Customer>(result);

            //以下执行完后才会去数据库中查询
            var customers      = result.ToList();
            var customerSearch = CustomerOperator.SetCustomerSearchModelCascade(customers);

            return(customerSearch);
        }