示例#1
0
        public ContainerQueryResponse Get(ContainerQuery query)
        {
            var response = new ContainerQueryResponse();

            using (_session)
            {
                try
                {
                    IEnumerable <Container> containers = _session.Query <Container>();

                    if (!string.IsNullOrEmpty(query.SourceFilter))
                    {
                        containers = from c in containers
                                     where c.Source.ToLower().Contains(query.SourceFilter.ToLower())
                                     select c;
                    }
                    if (query.NumberFilter.HasValue && query.NumberFilter > 0)
                    {
                        containers = from c in containers
                                     where c.Number == query.NumberFilter
                                     select c;
                    }
                    if (!string.IsNullOrEmpty(query.DescriptionFilter))
                    {
                        containers = from c in containers
                                     where c.Description.ToLower().Contains(query.DescriptionFilter.ToLower())
                                     select c;
                    }
                    if (query.DatePackedFilter.HasValue && query.DatePackedFilter > DateTime.MinValue)
                    {
                        containers = from c in containers
                                     where c.DatePacked == query.DatePackedFilter
                                     select c;
                    }
                    response.Containers = containers.ToArray();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Get(ContainerQuery): {0}", ex.Message);
                    throw;
                }
            }
            return(response);
        }
示例#2
0
        public ContainerQueryResponse Get(ContainerQuery query)
        {
            var response = new ContainerQueryResponse();
            using (_session)
            {
                try
                {
                    IEnumerable<Container> containers = _session.Query<Container>();

                    if (!string.IsNullOrEmpty(query.SourceFilter))
                    {
                        containers = from c in containers
                                     where c.Source.ToLower().Contains(query.SourceFilter.ToLower())
                                     select c;
                    }
                    if (query.NumberFilter.HasValue && query.NumberFilter > 0)
                    {
                        containers = from c in containers
                                     where c.Number == query.NumberFilter
                                     select c;
                    }
                    if (!string.IsNullOrEmpty(query.DescriptionFilter))
                    {
                        containers = from c in containers
                                     where c.Description.ToLower().Contains(query.DescriptionFilter.ToLower())
                                     select c;
                    }
                    if (query.DatePackedFilter.HasValue && query.DatePackedFilter > DateTime.MinValue)
                    {
                        containers = from c in containers
                                     where c.DatePacked == query.DatePackedFilter
                                     select c;
                    }
                    response.Containers = containers.ToArray();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Get(ContainerQuery): {0}", ex.Message);
                    throw;
                }
            }
            return response;
        }