public void NamedQuery_WhenStoredProcedureWithArgsHasResult_ReturnsItems()
        {
            IList<ItemForNamedQueries> refetched;
            using (var uow = Database.CreateUnitOfWork())
            {
                var query = new NamedQuery(ProcedureName);
                query.Add(new QueryParameter("minId", QueryForMinId), new QueryParameter("maxId", QueryForMaxId));
                refetched = uow.NamedQuery<ItemForNamedQueries>(query).ToList();
            }

            Assert.AreEqual(4, refetched.Count());
            CustomAssert.AreValueEqual(_items[2], refetched[0]);
            CustomAssert.AreValueEqual(_items[5], refetched[3]);
        }
        public void NamedQueryAsJson_WhenStoredProcedureWithArgsHasResult_ReturnsItems()
        {
            IList<string > refetchedJson;
            using (var uow = Database.CreateUnitOfWork())
            {
                var query = new NamedQuery(ProcedureName);
                query.Add(new QueryParameter("minId", QueryForMinId), new QueryParameter("maxId", QueryForMaxId));
                refetchedJson = uow.NamedQueryAsJson<ItemForNamedQueries>(query).ToList();
            }

            Assert.AreEqual(4, refetchedJson.Count());
            Assert.AreEqual("{\"Id\":3,\"SortOrder\":3}", refetchedJson[0]);
            Assert.AreEqual("{\"Id\":6,\"SortOrder\":6}", refetchedJson[3]);
        }
        public void NamedQuery_WhenStoredProcedureHasNoResult_NonNullEmptyResult()
        {
            var minIdOutsideScope = _items.Count + 1;
            var maxIdOutsideScope = minIdOutsideScope;

            IList<ItemForNamedQueries> refetched;
            using (var uow = Database.CreateUnitOfWork())
            {
                var query = new NamedQuery(ProcedureName);
                query.Add(new QueryParameter("minId", minIdOutsideScope), new QueryParameter("maxId", maxIdOutsideScope));
                refetched = uow.NamedQuery<ItemForNamedQueries>(query).ToList();
            }

            Assert.IsNotNull(refetched);
            Assert.AreEqual(0, refetched.Count());
        }
Esempio n. 4
0
        private static int GetCustomersViaSpRaw(ISisoDatabase database, int customerNoFrom, int customerNoTo)
        {
            var d = new DateTime(2012, 1, 1);
            using (var session = database.BeginSession())
            {
                var q = new NamedQuery("CustomersViaSP");
                q.Add(new DacParameter("p0", 10));
                q.Add(new DacParameter("p1", true));
                q.Add(new DacParameter("p2", d));
                q.Add(new DacParameter("p3", customerNoFrom));
                q.Add(new DacParameter("p4", customerNoTo));
                q.Add(new DacParameter("p5", "The delivery street #544"));

                return session.Advanced.NamedQuery<Customer>(q).ToArray().Length;
            }
        }