示例#1
0
        public void Find <T>(DataQueryBuilder dataQueryBuilder, AsyncCallback <IList <T> > callback)
        {
            var responder = new AsyncCallback <IList <T> >(r =>
            {
                if (callback != null)
                {
                    callback.ResponseHandler.Invoke(r);
                }
            }, f =>
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(f);
                }
                else
                {
                    throw new BackendlessException(f);
                }
            });

            if (dataQueryBuilder == null)
            {
                dataQueryBuilder = DataQueryBuilder.Create();
            }

            BackendlessDataQuery dataQuery = dataQueryBuilder.Build();

            AddWeborbPropertyMapping <T>();
            Invoker.InvokeAsync(PERSISTENCE_MANAGER_SERVER_ALIAS, "find",
                                new Object[] { GetTypeName(typeof(T)), dataQuery },
                                true,
                                responder);
        }
示例#2
0
        public void TestCollectionGetPage()
        {
            var getPageEntities = new List <GetPageEntity>();

            for (int i = 10; i < 30; i++)
            {
                var entity = new GetPageEntity {
                    Name = "name#" + i, Age = 20 + i
                };
                Backendless.Persistence.Save(entity);

                if (i > 19 && i < 30)
                {
                    getPageEntities.Add(entity);
                }

                Thread.Sleep(1000);
            }

            var dataQueryBuilder = DataQueryBuilder.Create().AddProperty("Age").SetPageSize(10);
            var collection       = Backendless.Persistence.Of <GetPageEntity>().Find(dataQueryBuilder.PrepareNextPage());

            Assert.IsNotNull(collection, "Next page returned a null object");
            Assert.AreEqual(getPageEntities.Count, collection.Count, "Next page returned a wrong size");

            foreach (GetPageEntity entity in getPageEntities)
            {
                Assert.IsTrue(collection.Contains(entity), "Server result didn't contain expected entity");
            }
        }
示例#3
0
        public void TestPersistenceServiceFindById_StringId_Async()
        {
            List <Dictionary <String, Object> > listPerson = new List <Dictionary <String, Object> >();
            Dictionary <String, Object>         person     = new Dictionary <String, Object>();

            person["age"]  = 15;
            person["name"] = "Alexandra";

            List <String> listId = new List <String>();

            listPerson.Add(person);
            listId = (List <String>)Backendless.Data.Of("Person").Create(listPerson);

            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("age");
            Backendless.Data.Of("Person").FindById(listId[0], queryBuilder, new AsyncCallback <Dictionary <String, Object> >(
                                                       callback =>
            {
                Assert.IsNotNull(callback);
                Assert.AreEqual(callback["objectId"], listId[0], "Object id were not equivalent");
                Assert.IsFalse(callback.ContainsKey("name"));
                Assert.IsTrue(callback.ContainsKey("age"));
            },
                                                       fault =>
            {
                throw new ArgumentException("Error");
            }));

            Backendless.Data.Of("Person").Remove("age = '15'");
        }
        public void TestDeleteSingleObject_OpResult()
        {
            List <Person> personList   = new List <Person>();
            Person        personObject = new Person();

            personObject.name = "Bob";
            personObject.age  = 23;
            personList.Add(personObject);
            String objectId = Backendless.Data.Of <Person>().Create(personList)[0];

            UnitOfWork uow = new UnitOfWork();

            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.SetWhereClause("age = '23'");

            OpResult opResult = uow.Find("Person", queryBuilder);
            OpResultValueReference firstInvalid = opResult.ResolveTo(0);

            uow.Delete(firstInvalid);

            UnitOfWorkResult uowResult = uow.Execute();

            Assert.IsTrue(uowResult.Success);
            Assert.IsNotNull(uowResult.Results);

            IList <Person> listCheckPerson = Backendless.Data.Of <Person>().Find();

            Assert.IsTrue(listCheckPerson.Count == 0);
        }
示例#5
0
        public async Task <IEnumerable <Acquaintance> > GetItems()
        {
            await EnsureDataIsSeededAsync();

            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.SetPageSize(100);
            queryBuilder.SetWhereClause($"DataPartitionId = '{_DataPartitionId}'");
            List <String> sortByList = new List <string>();

            sortByList.Add("LastName");
            queryBuilder.SetSortBy(sortByList);

            IList <Acquaintance> items = await Backendless.Data.Of <Acquaintance>().FindAsync(queryBuilder);

            if (items.Count == 0)
            {
                Settings.DataIsSeeded = false;
                await EnsureDataIsSeededAsync();

                return(await GetItems());
            }

            return(items);
        }
示例#6
0
        public void TestFindWithMissingProperties()
        {
            RunAndAwait(() =>
            {
                var findWithPropertiesEntity = new FindWithPropertiesEntityAsync {
                    Name = "bot_#foobar", Age = 20
                };
                Backendless.Persistence.Save(findWithPropertiesEntity,
                                             new ResponseCallback <FindWithPropertiesEntityAsync>(this)
                {
                    ResponseHandler = response =>
                    {
                        var dataQueryBuilder = DataQueryBuilder.Create().AddProperty("foobar");

                        Backendless.Persistence.Of <FindWithPropertiesEntityAsync>()
                        .Find(dataQueryBuilder,
                              new AsyncCallback
                              <IList <FindWithPropertiesEntityAsync> >
                                  (collection =>
                                  Assert.Fail("Server didn't throw an exception"),
                                  fault => CheckErrorCode(1006, fault)));
                    }
                });
            });
        }
示例#7
0
        async Task EnsureDataIsSeededAsync()
        {
            if (Settings.DataIsSeeded)
            {
                return;
            }

            int count = 0;

            try
            {
                await Backendless.Data.Of <Acquaintance>().GetObjectCountAsync(DataQueryBuilder.Create().SetWhereClause($"DataPartitionId = '{_DataPartitionId}'"));
            }
            catch (Exception)
            {
            }

            if (count > 0)
            {
                Settings.DataIsSeeded = true;
            }

            if (!Settings.DataIsSeeded)
            {
                var newItems = SeedData.Get(_DataPartitionId);

                await Backendless.Data.Of <Acquaintance>().CreateAsync(newItems);

                Settings.DataIsSeeded = true;
            }
        }
        public void Find(DataQueryBuilder dataQueryBuilder, AsyncCallback <IList <Dictionary <String, Object> > > callback)
        {
            var responder = new AsyncCallback <IList <Dictionary <String, Object> > >(
                r =>
            {
                if (callback != null)
                {
                    callback.ResponseHandler.Invoke(r);
                }
            },
                f =>
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(f);
                }
                else
                {
                    throw new BackendlessException(f);
                }
            });

            if (dataQueryBuilder == null)
            {
                dataQueryBuilder = DataQueryBuilder.Create();
            }

            BackendlessDataQuery dataQuery = dataQueryBuilder.Build();

            Object[] args = { tableName, dataQuery };
            Invoker.InvokeAsync(PERSISTENCE_MANAGER_SERVER_ALIAS, "find", args, responder);
        }
示例#9
0
        public void TestFind_AllObjects()
        {
            List <Person> listPerson     = new List <Person>();
            Person        personCreated1 = new Person();

            personCreated1.age  = 17;
            personCreated1.name = "Alexandra";

            Person personCreated2 = new Person();

            personCreated2.age  = 24;
            personCreated2.name = "Joe";

            listPerson.Add(personCreated1);
            listPerson.Add(personCreated2);
            IList <String> objectIds = Backendless.Data.Of <Person>().Create(listPerson);

            UnitOfWork uow = new UnitOfWork();
            OpResult   opResultCreateBulkPerson = uow.BulkCreate(listPerson);
            OpResult   opResultFindPerson       = uow.Find("Person", DataQueryBuilder.Create());

            UnitOfWorkResult uowResult = uow.Execute();

            Assert.IsTrue(uowResult.Success);
            Dictionary <String, OperationResult> results = uowResult.Results;

            Assert.IsTrue(2 == results.Count);

            Dictionary <Object, Object>[] resultFind = (Dictionary <Object, Object>[])results[opResultFindPerson.OpResultId].Result;
            Assert.IsTrue(4 == resultFind.Length);

            Backendless.Data.Of("Person").Remove("age > '15'");
        }
示例#10
0
        public void TestPersistenceServiceFindById_Dictionary()
        {
            List <Dictionary <String, Object> > listPerson = new List <Dictionary <String, Object> >();
            Dictionary <String, Object>         person     = new Dictionary <String, Object>();

            person["age"]  = 15;
            person["name"] = "Alexandra";

            List <String> listId = new List <String>();

            listPerson.Add(person);
            listId = (List <String>)Backendless.Data.Of("Person").Create(listPerson);

            person["objectId"] = listId[0];
            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("age");
            Dictionary <String, Object> result = Backendless.Data.Of("Person").FindById(person, queryBuilder);

            Assert.IsNotNull(result);
            Assert.AreEqual(result["objectId"], listId[0], "Object id were not equivalent");
            Assert.IsFalse(result.ContainsKey("name"));
            Assert.IsTrue(result.ContainsKey("age"));

            Backendless.Data.Of("Person").Remove("age = '15'");
        }
示例#11
0
        public void TestDeleteBulkObjects_OpResult()
        {
            List <Person> personList   = new List <Person>();
            Person        firstPerson  = new Person();
            Person        secondPerson = new Person();

            firstPerson.age   = 22;
            firstPerson.name  = "John";
            secondPerson.age  = 12;
            secondPerson.name = "Ivie";
            personList.Add(firstPerson);
            personList.Add(secondPerson);

            UnitOfWork uow = new UnitOfWork();

            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.SetWhereClause("age > '10'");

            OpResult invalidName = uow.Find("Person", queryBuilder);

            uow.BulkDelete(invalidName);

            UnitOfWorkResult uowResult = uow.Execute();

            Assert.IsTrue(uowResult.Success);
            Assert.IsNotNull(uowResult.Results);

            IList <Person> listCheckPerson = Backendless.Data.Of <Person>().Find();

            Assert.IsTrue(listCheckPerson.Count == 0);
        }
示例#12
0
        public void TestCollectionGetPage()
        {
            RunAndAwait(() =>
            {
                var getPageEntities = new List <GetPageEntityAsync>();
                var latch           = new CountdownEvent(20);
                for (int i = 10; i < 30; i++)
                {
                    var entity = new GetPageEntityAsync {
                        Name = "name#" + i, Age = 20 + i
                    };
                    Backendless.Persistence.Save(entity,
                                                 new AsyncCallback <GetPageEntityAsync>(response => latch.Signal(), fault =>
                    {
                        for (int j = 0; j < latch.CurrentCount; j++)
                        {
                            latch.Signal();
                        }
                    }));

                    if (i > 19 && i < 30)
                    {
                        getPageEntities.Add(entity);
                    }
                }
                latch.Wait();

                var dataQueryBuilder = DataQueryBuilder.Create().AddProperty("Age").SetPageSize(10).SetOffset(0);
                Backendless.Persistence.Of <GetPageEntityAsync>()
                .Find(dataQueryBuilder,
                      new ResponseCallback <IList <GetPageEntityAsync> >(this)
                {
                    ResponseHandler =
                        response =>
                        Backendless.Persistence.Of <GetPageEntityAsync>().Find(dataQueryBuilder.PrepareNextPage(),
                                                                               new ResponseCallback <IList <GetPageEntityAsync> >(this)
                    {
                        ResponseHandler = collection =>
                        {
                            Assert.IsNotNull(collection, "Next page returned a null object");
                            Assert.AreEqual(getPageEntities.Count,
                                            collection.Count,
                                            "Next page returned a wrong size");

                            foreach (GetPageEntityAsync entity in getPageEntities)
                            {
                                Assert.IsTrue(
                                    collection.Contains(entity),
                                    "Server result didn't contain expected entity");
                            }

                            CountDown();
                        }
                    })
                });
            });
        }
示例#13
0
        public void TestFind_CheckError()
        {
            UnitOfWork uow = new UnitOfWork();

            uow.Find("Wrong table name", DataQueryBuilder.Create());
            UnitOfWorkResult uowResult = uow.Execute();

            Assert.IsFalse(uowResult.Success);
            Assert.IsNull(uowResult.Results);
        }
示例#14
0
        public void TestWhereClauseZero()
        {
            DataQueryBuilder qb = DataQueryBuilder.Create();

            qb.AddAllProperties();
            qb.SetWhereClause("name='Joe'");
            IList <Dictionary <String, Object> > res = Backendless.Data.Of("Orders").Find(qb);

            Assert.IsTrue(res.Count == 0);
        }
示例#15
0
        public void TestAddRelation_OpResult()
        {
            List <Person> listPerson = new List <Person>();
            Person        personObj  = new Person();

            personObj.age  = 22;
            personObj.name = "Eva";
            listPerson.Add(personObj);

            IList <String> parentObjIds = Backendless.Data.Of <Person>().Create(listPerson);

            listPerson.Clear();
            personObj.objectId = parentObjIds[0];

            List <Order> listOrder = new List <Order>();
            Order        orderObj  = new Order();

            orderObj.LastName = "Smith";
            listOrder.Add(orderObj);
            List <Dictionary <String, Object> > listChildObjMap = new List <Dictionary <String, Object> >();
            Dictionary <String, Object>         childObjMap     = new Dictionary <String, Object>();

            childObjMap["LastName"] = "Smith";
            listChildObjMap.Add(childObjMap);

            IList <String> childObjIds = Backendless.Data.Of("Order").Create(listChildObjMap);

            listChildObjMap.Clear();
            childObjMap["objectId"] = childObjIds[0];
            listChildObjMap.Add(childObjMap);

            UnitOfWork uow = new UnitOfWork();

            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.SetWhereClause("LastName in ('Smith')");

            OpResult gifts          = uow.Find("Order", queryBuilder);
            String   relationColumn = "Surname";

            uow.AddToRelation(personObj.GetType().Name, personObj.objectId, relationColumn, gifts);
            UnitOfWorkResult uowResult = uow.Execute();

            Assert.IsTrue(uowResult.Success);
            Assert.IsNotNull(uowResult.Results);

            DataQueryBuilder dqb = DataQueryBuilder.Create();

            dqb.SetRelationsPageSize(10);
            dqb.SetRelationsDepth(10);
            IList <Person> listCheckPersonObj = Backendless.Data.Of <Person>().Find(dqb);

            Assert.IsTrue(listCheckPersonObj.Count == 1);
            Assert.IsTrue(listCheckPersonObj[0].Surname != null);
        }
示例#16
0
        public void TestCreateFieldTIME()
        {
            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("*", "TIME(created) as myTime");

            IList <Dictionary <String, Object> > res = Backendless.Data.Of("Person").Find(queryBuilder);

            Assert.IsTrue(res[0].ContainsKey("myTime"), "First object does not contain 'myTime' key");
            Assert.IsTrue(res[1].ContainsKey("myTime"), "Second object does not contain 'myTime' key");
        }
        public void TestDeleteRelation_Dictionary()
        {
            List <Dictionary <String, Object> > listObjMap = new List <Dictionary <String, Object> >();
            Dictionary <String, Object>         parentObj  = new Dictionary <String, Object>();
            Dictionary <String, Object>         childObj   = new Dictionary <String, Object>();

            parentObj["name"] = "Eva";
            parentObj["age"]  = 22;

            childObj["LastName"] = "Smith";
            listObjMap.Add(parentObj);

            IList <String> parentId = Backendless.Data.Of("Person").Create(listObjMap);

            parentObj["objectId"] = parentId[0];
            listObjMap.Clear();
            listObjMap.Add(childObj);

            List <String> childId = (List <String>)Backendless.Data.Of("Order").Create(listObjMap);

            listObjMap.Clear();
            childObj["objectId"] = childId[0];
            listObjMap.Add(childObj);

            String relationColumnName = "Surname";

            Backendless.Data.Of("Person").AddRelation(parentObj, relationColumnName, listObjMap.ToArray());

            DataQueryBuilder dqb = DataQueryBuilder.Create();

            dqb.SetRelationsDepth(10);
            dqb.SetRelationsPageSize(10);

            IList <Dictionary <String, Object> > objectBefore_DeleteRelation = Backendless.Data.Of("Person").Find(dqb);

            Assert.IsTrue(objectBefore_DeleteRelation[0]["Surname"] != null);

            listObjMap.Clear();
            childObj["objectId"] = childId[0];
            listObjMap.Add(childObj);

            UnitOfWork uow = new UnitOfWork();

            uow.DeleteRelation("Person", parentId[0], relationColumnName, listObjMap);

            UnitOfWorkResult uowResult = uow.Execute();

            Assert.IsTrue(uowResult.Success);
            Assert.IsNotNull(uowResult.Results);

            IList <Dictionary <String, Object> > objectAfter_DeleteRelation = Backendless.Data.Of("Person").Find(dqb);

            Assert.IsNull(objectAfter_DeleteRelation[0]["Surname"]);
        }
示例#18
0
        public void TestRelatedField()
        {
            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.AddProperties("*", "Location.adress");

            IList <Dictionary <String, Object> > res = Backendless.Data.Of("Person").Find(queryBuilder);

            Assert.IsTrue(res[0].ContainsKey("adress"), "First object does not contain 'adress' field");
            Assert.IsTrue(res[1].ContainsKey("adress"), "Second object does not contain 'adress' field");
        }
        public static DataQueryBuilder BackendlessDataQueryToDataQueryBuilder(BackendlessDataQuery dataQuery)
        {
            DataQueryBuilder dataQueryBuilder = DataQueryBuilder.Create();

            if (!string.IsNullOrEmpty(dataQuery.WhereClause))
            {
                dataQueryBuilder.SetWhereClause(dataQuery.WhereClause);
            }

            if (dataQuery.Offset > 0)
            {
                dataQueryBuilder.SetOffset(dataQuery.Offset);
            }

            if (dataQuery.PageSize > 0)
            {
                dataQueryBuilder.SetPageSize(dataQuery.PageSize);
            }

            if (dataQuery.Properties != null)
            {
                dataQueryBuilder.SetProperties(dataQuery.Properties);
            }

            if (dataQuery.QueryOptions != null)
            {
                if (dataQuery.QueryOptions.Offset > 0)
                {
                    dataQueryBuilder.SetOffset(dataQuery.QueryOptions.Offset);
                }

                if (dataQuery.QueryOptions.PageSize > 0)
                {
                    dataQueryBuilder.SetPageSize(dataQuery.QueryOptions.PageSize);
                }

                if (dataQuery.QueryOptions.Related != null)
                {
                    dataQueryBuilder.SetRelated(dataQuery.QueryOptions.Related);
                }

                if (dataQuery.QueryOptions.RelationsDepth > 0)
                {
                    dataQueryBuilder.SetRelationsDepth(dataQuery.QueryOptions.RelationsDepth);
                }

                if (dataQuery.QueryOptions.SortBy != null)
                {
                    dataQueryBuilder.SetSortBy(dataQuery.QueryOptions.SortBy);
                }
            }

            return(dataQueryBuilder);
        }
示例#20
0
        public void TestRelationsWithClass()
        {
            DataQueryBuilder qb = DataQueryBuilder.Create();

            qb.AddAllProperties();
            qb.SetRelated(new List <String> {
                "Related"
            });
            IList <Orders> res = Backendless.Data.Of <Orders>().Find(qb);

            Assert.IsTrue(res[0].Related.Count == 1);
        }
示例#21
0
 public static async Task <IList <Dictionary <String, Object> > > FindWithSortAsync(String tableName, String sortBy)
 {
     try
     {
         return(await Backendless.Data.Of($"{tableName}")
                .FindAsync(DataQueryBuilder.Create().AddSortBy(sortBy)));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
示例#22
0
        public void TestSetRelation_Dictionary()
        {
            List <Dictionary <String, Object> > listMaps  = new List <Dictionary <String, Object> >();
            Dictionary <String, Object>         objectMap = new Dictionary <String, Object>();

            objectMap["age"]  = 22;
            objectMap["name"] = "Eva";
            listMaps.Add(objectMap);

            IList <String> parentObjIds = Backendless.Data.Of("Person").Create(listMaps);

            listMaps.Clear();
            objectMap["objectId"] = parentObjIds[0];

            List <Order> listOrder = new List <Order>();
            Order        orderObj  = new Order();

            orderObj.LastName = "Smith";
            listOrder.Add(orderObj);
            List <Dictionary <String, Object> > listChildObjMap = new List <Dictionary <String, Object> >();
            Dictionary <String, Object>         childObjMap     = new Dictionary <String, Object>();

            childObjMap["LastName"] = "Smith";
            listChildObjMap.Add(childObjMap);



            IList <String> childObjIds = Backendless.Data.Of("Order").Create(listChildObjMap);

            listChildObjMap.Clear();
            childObjMap["objectId"] = childObjIds[0];
            listChildObjMap.Add(childObjMap);

            String relationColumn = "Surname";

            UnitOfWork uow = new UnitOfWork();

            uow.SetRelation("Person", objectMap, relationColumn, childObjIds.ToArray());
            UnitOfWorkResult uowResult = uow.Execute();

            Assert.IsTrue(uowResult.Success);
            Assert.IsNotNull(uowResult.Results);

            DataQueryBuilder dqb = DataQueryBuilder.Create();

            dqb.SetRelationsPageSize(10);
            dqb.SetRelationsDepth(10);
            IList <Person> listCheckPersonObj = Backendless.Data.Of <Person>().Find(dqb);

            Assert.IsTrue(listCheckPersonObj.Count == 1);
            Assert.IsTrue(listCheckPersonObj[0].Surname != null);
        }
        public void TestDeleteRelation_OpResult()
        {
            List <Person> listObjects  = new List <Person>();
            Person        personObject = new Person();

            personObject.age  = 22;
            personObject.name = "Jia";
            listObjects.Add(personObject);

            List <Order> childObject = new List <Order>();
            Order        orderObject = new Order();

            orderObject.LastName = "Smith";

            personObject.objectId = Backendless.Data.Of <Person>().Create(listObjects)[0];

            childObject.Add(orderObject);
            orderObject.objectId = Backendless.Data.Of <Order>().Create(childObject)[0];

            childObject.Clear();
            childObject.Add(orderObject);

            String relationColumn = "Surname";

            Backendless.Data.Of <Person>().AddRelation(personObject, relationColumn, childObject.ToArray());

            DataQueryBuilder dqb = DataQueryBuilder.Create();

            dqb.SetRelationsDepth(10);
            dqb.SetRelationsPageSize(10);

            IList <Dictionary <String, Object> > objectBefore_DeleteRelation = Backendless.Data.Of("Person").Find(dqb);

            Assert.IsTrue(objectBefore_DeleteRelation[0]["Surname"] != null);

            DataQueryBuilder queryBuilder = DataQueryBuilder.Create();

            queryBuilder.SetWhereClause("LastName in ('Smith')");

            UnitOfWork uow   = new UnitOfWork();
            OpResult   gifts = uow.Find("Order", queryBuilder);

            uow.DeleteRelation(personObject.GetType().Name, personObject.objectId, relationColumn, gifts);
            UnitOfWorkResult uowResult = uow.Execute();

            Assert.IsTrue(uowResult.Success);
            Assert.IsNotNull(uowResult.Results);

            IList <Dictionary <String, Object> > objectAfter_DeleteRelation = Backendless.Data.Of("Person").Find(dqb);

            Assert.IsNull(objectAfter_DeleteRelation[0]["Surname"]);
        }
示例#24
0
        public void TestGroupBy()
        {
            DataQueryBuilder qb = DataQueryBuilder.Create();

            qb.AddAllProperties();
            qb.AddGroupBy("Percentage");
            IList <Dictionary <String, Object> > res = Backendless.Data.Of("CountryLanguage").Find(qb);

            foreach (Dictionary <String, Object> entry in res)
            {
                Assert.IsTrue(entry.ContainsKey("Percentage"));
            }
        }
示例#25
0
        public void TestWhereClauseNotZero()
        {
            DataQueryBuilder qb = DataQueryBuilder.Create();

            qb.AddAllProperties();
            qb.SetWhereClause("Percentage > 30");
            IList <Dictionary <String, Object> > res = Backendless.Data.Of("CountryLanguage").Find(qb);

            foreach (Dictionary <String, Object> entry in res)
            {
                Assert.IsTrue((Double)entry["Percentage"] > 30.0);
            }
        }
        public IList <Dictionary <String, Object> > Find(DataQueryBuilder dataQueryBuilder)
        {
            if (dataQueryBuilder == null)
            {
                dataQueryBuilder = DataQueryBuilder.Create();
            }

            BackendlessDataQuery dataQuery = dataQueryBuilder.Build();

            PersistenceService.CheckPageSizeAndOffset(dataQuery);

            Object[] args = { tableName, dataQuery };
            return(Invoker.InvokeSync <IList <Dictionary <String, Object> > >(PERSISTENCE_MANAGER_SERVER_ALIAS, "find", args));
        }
示例#27
0
        internal T FindByIdViaDataQueryBuilder <T>(String id, DataQueryBuilder queryBuilder)
        {
            if (id == null)
            {
                throw new ArgumentException(ExceptionMessage.NULL_ID);
            }

            if (queryBuilder == null)
            {
                queryBuilder = DataQueryBuilder.Create();
            }

            return(Invoker.InvokeSync <T>(PERSISTENCE_MANAGER_SERVER_ALIAS, "findById", new Object[] { id, queryBuilder }, true));
        }
示例#28
0
        public void TestRelations()
        {
            DataQueryBuilder qb = DataQueryBuilder.Create();

            qb.AddAllProperties();
            qb.SetRelated(new List <String>()
            {
                "Related"
            });
            IList <Dictionary <String, Object> > res = Backendless.Data.Of("Orders").Find(qb);

            Assert.IsTrue(res[0].ContainsKey("Related"));
            Assert.IsTrue(res[1].ContainsKey("Related"));
        }
示例#29
0
        public void TestSort()
        {
            DataQueryBuilder qb = DataQueryBuilder.Create();

            qb.AddAllProperties();
            qb.SetRelated(new List <String> {
                "Related"
            });
            qb.SetSortBy(new List <String> {
                "age"
            });
            IList <Dictionary <String, Object> > res = Backendless.Data.Of("Orders").Find(qb);

            Assert.IsTrue((Double)res[0]["age"] < (Double)res[1]["age"]);
        }
示例#30
0
        public void TestRelationPageSizeZero()
        {
            DataQueryBuilder qb = DataQueryBuilder.Create();

            qb.AddAllProperties();
            qb.SetRelationsPageSize(0);
            qb.SetRelated(new List <String> {
                "Related"
            });
            IList <Dictionary <String, Object> > res = Backendless.Data.Of("Orders").Find(qb);

            Object[] rel = (Object[])res[0]["Related"];

            Assert.IsTrue(rel.Length == 0);
        }