public IList <RecargaSUBE> GetRecargaMasCercanos(Point origen, int count)
        {
            var session = sessionFactory.GetCurrentSession();
            var query   = session.CreateQuery(@"select r from RecargaSUBE r
                                        order by NHSP.Distance(r.Ubicacion, :coord)")
                          .SetParameter("coord", origen, NHibernateUtil.Custom(typeof(Wgs84GeographyType)))
                          .SetMaxResults(count);

            return(query.List <RecargaSUBE>());
        }
        public IList <Transporte> GetMasCercanos(Point origen, int maxDistance)
        {
            var session = sessionFactory.GetCurrentSession();
            var query   = session.CreateQuery(@"select t from Transporte t 
                                        where NHSP.Distance(t.Ubicacion, :coord) <= :maxDistance 
                                        order by NHSP.Distance(t.Ubicacion, :coord)")
                          .SetParameter("coord", origen, NHibernateUtil.Custom(typeof(Wgs84GeographyType)))
                          .SetDouble("maxDistance", maxDistance);

            return(query.List <Transporte>());
        }
Esempio n. 3
0
        private static IList <AddressQM> ListNHSql()
        {
            var session = SessionFactory.GetSession();
            var sql     = session.CreateSQLQuery("SELECT Street, Coordinates, Date FROM Address Where ZipCode = :ZipCode")
                          .AddScalar("Street", NHibernateUtil.String)
                          .AddScalar("Coordinates", NHibernateUtil.Custom(typeof(GeometryType)))
                          .AddScalar("Date", NHibernateUtil.Date);

            sql.SetResultTransformer(Transformers.AliasToBean <AddressQM>());
            sql.SetString("ZipCode", ran.Next(5000).ToString());
            sql.SetMaxResults(15);
            return(sql.List <AddressQM>());
        }
Esempio n. 4
0
        public async Task EqualityWorksForExplicitUserTypeAsync()
        {
            using (var session = OpenSession())
                using (session.BeginTransaction())
                {
                    var newItem = new BarExample {
                        Value = "Larry"
                    };
                    var entities = await(session.Query <EntityWithUserTypeProperty>()
                                         .Where(x => x.Example == newItem.MappedAs(NHibernateUtil.Custom(typeof(ExampleUserType))))
                                         .ToListAsync());

                    Assert.AreEqual(1, entities.Count);
                }
        }
        public void OrderByDistanceHql()
        {
            var point = new Point(0.0, 0.0)
            {
                SRID = 4326
            };

            var result = _session.CreateQuery(
                @"select p from Simple p
                  order by NHSP.Distance(p.Geometry, :point)")
                         .SetParameter("point", point, NHibernateUtil.Custom(GeometryType))
                         .List <Simple>();

            Assert.That(result[0].Description, Is.EqualTo("point 2"));
            Assert.That(result[1].Description, Is.EqualTo("point 4"));
            Assert.That(result[2].Description, Is.EqualTo("point 3"));
            Assert.That(result[3].Description, Is.EqualTo("point 1"));
        }
Esempio n. 6
0
        public void LinqMethodWorksForExplicitUserType()
        {
            using (var session = OpenSession())
                using (session.BeginTransaction())
                {
                    var newItem = new BarExample {
                        Value = "Larry"
                    };
                    var entities = session.Query <EntityWithUserTypeProperty>()
                                   .Where(x => x.Example.IsEquivalentTo(newItem.MappedAs(NHibernateUtil.Custom(typeof(ExampleUserType)))))
                                   .ToList();

                    Assert.AreEqual(2, entities.Count);
                }
        }