Ejemplo n.º 1
0
        public void Expression_Test()
        {
            var query = new QueryMunicipalityByName
            {
                Name = "Name"
            };

            var data = new[]
            {
                new Municipality
                {
                    Name = "A"
                },
                new Municipality
                {
                    Name = "Name",
                },
                new Municipality
                {
                    Name = "B"
                },
            };

            var result = data.SingleOrDefault(query.Expression.Compile());

            Assert.AreEqual("Name", result?.Name);
        }
Ejemplo n.º 2
0
    private IEnumerable <Municipality> FindMunicipalitiesByNameWithDiscrict(string municipalityName)
    {
        if (municipalityName == null)
        {
            return(new Municipality[0]);
        }

        IQuery <Municipality> query;

        if (municipalityName.Contains(","))
        {
            var parts = municipalityName.Split(',');
            query = new QueryMunicipalityByNameAndDistrict
            {
                Name     = parts[0],
                District = parts[1]
            };
        }
        else
        {
            query = new QueryMunicipalityByName
            {
                Name = municipalityName
            };
        }

        return(MunicipalityRepository.FindAll(query));
    }