public Task <int> CountAsync() { return(Task.Factory.StartNew(() => { using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) { return _innerQuery.Count(); } })); }
// void rundb() // { // FirebaseOptions firebaseOptions = new FirebaseOptions.Builder().SetApiKey(" AIzaSyBQev9ULBFWqD31zfTr8ovFSGlURNDM2S4 ").SetDatabaseUrl("https://eticaret-feebb.firebaseio.com/").SetApplicationId("eticaret-feebb").Build(); // FirebaseApp firebaseApp = FirebaseApp.InitializeApp(this, firebaseOptions); // FirebaseDatabase firebaseDatabase = FirebaseDatabase.GetInstance(firebaseApp); // DatabaseReference databaseReference = firebaseDatabase.Reference.Database.Reference; // databaseReference.AddChildEventListener(this); // databaseReference.AddValueEventListener(this); // databaseReference.Child("Person").SetValue(new Person() { name = "mali", age = 20 }).AddOnCompleteListener(this).AddOnFailureListener(this); // } //async Task RunAsycn() // { // FirebaseOptions firebaseOptions = new FirebaseOptions.Builder().SetApiKey(" AIzaSyBQev9ULBFWqD31zfTr8ovFSGlURNDM2S4 ").SetDatabaseUrl("https://eticaret-feebb.firebaseio.com/").SetApplicationId("eticaret-feebb").Build(); // FirebaseApp firebaseApp = FirebaseApp.InitializeApp(this, firebaseOptions); // FirebaseDatabase firebaseDatabase = FirebaseDatabase.GetInstance(firebaseApp); // DatabaseReference databaseReference = firebaseDatabase.Reference.Database.Reference; // databaseReference.AddChildEventListener(this); // databaseReference.AddValueEventListener(this); // // databaseReference.Push().Child("Person").SetValue(new Person() { name = "mali", age = 20 }).AddOnCompleteListener(this).AddOnFailureListener(this); // await databaseReference.Child("Person").SetValueAsync(new Person() { name = "mali", age = 20 }); // //databaseReference.NotifyAll(); // } #endregion void CreateItems(TableQuery <Product> products) { //clear all views on the grid layout so I can create what I want to create mainLayout.RemoveAllViews(); //read the database and get the image and product id and create all for (int i = 0; i < products.Count(); i++) { LinearLayout linearLayout = (LinearLayout)LayoutInflater.Inflate(Resource.Layout.basicCart, null); Button button = linearLayout.FindViewById <Button>(Resource.Id.cartShowButton); button.Tag = products.ElementAt(i).ProductID; button.Click += Button_Click; ImageView image = linearLayout.FindViewById <ImageView>(Resource.Id.cartImage); image.SetImageDrawable(GetDrawable(products.ElementAt(i).ProductImage)); #region No need for now //linearLayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); //linearLayout.LayoutParameters.Width = DpToPixel(this, 180); //linearLayout.LayoutParameters.Height = DpToPixel(this, 150); //linearLayout.Orientation = Orientation.Vertical; //ImageView image = View.Inflate(this,) //image.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); //image.LayoutParameters.Width = DpToPixel(this, 154); //image.LayoutParameters.Height = DpToPixel(this, 93); //image.SetImageResource(Resource.Drawable.sportShoe); //image.SetForegroundGravity(GravityFlags.Center); //linearLayout.AddView(image); //Button button = new Button(this); //button.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); ////set buttons tag to its product id so when we click the button we can find the product that ////we are looking for //button.LayoutParameters.Width = DpToPixel(this, 90); //button.LayoutParameters.Height = DpToPixel(this, 35); //button.Text = "VIEW"; //Drawable img = GetDrawable(Resource.Drawable.search); // //img.Wait(); //img.SetBounds(0, 0, 100, 80); //button.SetCompoundDrawables(img, null, null, null); //button.CompoundDrawableTintList = GetColorStateList(Resource.Color.white); //button.Gravity = GravityFlags.CenterHorizontal; //button.SetBackgroundColor(Android.Graphics.Color.ParseColor("#FFAA66CC")); //button.TextAlignment = TextAlignment.Center; //button.SetTextColor(GetColorStateList(Resource.Color.white)); //button.Tag = i; //button.Click += Button_Click; //linearLayout.AddView(button); //gridLayout.Wait(); #endregion mainLayout.AddView(linearLayout); } }
public Task <int> CountAsync() { return(Task.Factory.StartNew(() => { using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) { return _innerQuery.Count(); } }, CancellationToken.None, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default)); }
public static User CheckUserInfo(string Username, string password) { TableQuery <User> tableQuery = _connection.Table <User>().Where(x => x.Username == Username); if (tableQuery.Count() == 0) { return(null); } return(tableQuery.First());; }
public static List <Tag> GetTagByPidStatic(string pid) { TableQuery <Tag> table = connection.Table <Tag>().Where(x => x.PID == pid); if (table.Count() == 0) { return(null); } else { int count = table.Count(); List <Tag> list = new List <Tag>(count); for (int i = 0; i < count; i++) { list.Add(table.ElementAt(i)); } return(list); } }
public static User GetUserById(int Id) { TableQuery <User> tableQuery = _connection.Table <User>().Where(x => x.Id == Id); if (tableQuery.Count() == 0) { return(null); } return(tableQuery.First()); }
public Node GetNodeByID(string ID) { TableQuery <Node> table = connection.Table <Node>().Where(x => x.ID == ID); if (table.Count() == 0) { return(null); } return(table.First()); }
public Task <int> CountAsync(CancellationToken cancellationToken = default(CancellationToken)) { return(Task.Factory.StartNew(() => { cancellationToken.ThrowIfCancellationRequested(); using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) { return _innerQuery.Count(); } }, cancellationToken, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default)); }
internal static T RetrieveFirst <T>(this TableQuery <T> query) { if (query.Count() == 0) { throw new Database.NotFoundException(); } else { return(query.First()); } }
/// <summary> /// Read the list of items. /// </summary> public List <TEntity> Read() { var returnItem = new List <TEntity> (); TableQuery <TEntity> itemList = DatabaseConnection.Table <TEntity> (); for (int i = 0; i < itemList.Count(); i++) { returnItem.Add(itemList.ElementAt(i)); } return(returnItem); }
public string GetSettings(string Name) { TableQuery <SettingsItem> results = db.Table <SettingsItem>().Where(s => s.name == Name); if (results.Count() > 0) { return(results.First().value); } else { return(""); } }
public void UseSail(Sail s) { TableQuery <Sail> activeSails = MainGameController.instance.databaseController.connection.Table <Sail>().Where(x => x.Active == true); if (activeSails.Count() > 0) { Sail curActive = activeSails.First(); curActive.Active = false; curActive.Save(); } s.Active = true; s.Save(); UpdateSailBuyPanels(); }
public string GetUserPasswd(string username, string hash) { TableQuery <User> found = _connection.Table <User>(). Where(v => v.name == username && v.passwd == hash); if (found.Count() == 1) { return(found.First().passwd); } else { return(string.Empty); } }
private List <queryResult> createResultList(TableQuery <Student> query) { List <queryResult> results = new List <queryResult>(); string buffer; int num = 0; if (query.Count() == 0) { results.Add(new queryResult { Title = "查無資料!", StuInfo = " " }); } else { foreach (var stu in query) { if (num >= 40) { break; } if (stu.sex == "male") { buffer = "男"; } else if (stu.sex == "female") { buffer = "女"; } else { buffer = " 無資料"; } if (stu.course == "none") { buffer += " 無系上資料"; } else { buffer += " " + stu.course; } results.Add(new queryResult { Title = stu.stuID + " " + stu.name, StuInfo = buffer }); num++; } } return(results); }
public void LoadFromStorage() { using (var connection = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), C.DB_PATH)) { var cmd = connection.CreateCommand($"SELECT name FROM sqlite_master WHERE type='table' AND name='{typeof(Todo).Name}'"); if (cmd.ExecuteScalar <string>() == null) { connection.CreateTable <Todo>(SQLite.Net.Interop.CreateFlags.None); } TableQuery <Todo> q = connection.Table <Todo>(); _instance.Todos.Clear(); for (int i = 0; i < q.Count(); ++i) { Todos.Add(q.ElementAt(i)); } } }
/// <summary> /// /// </summary> /// <returns></returns> public List <Muscle> Find(MuscleCriteria muscleCriteria = null) { List <Muscle> resultList = null; TableQuery <MuscleRow> rowList = _dbContext.Table <MuscleRow>(); CriteriaTransformer.CompleteQuery(ref rowList, muscleCriteria); if (rowList != null && rowList.Count() > 0) { resultList = new List <Muscle>(); foreach (var row in rowList) { resultList.Add(MuscleTransformer.ToBean(row)); } } return(resultList); }
/// <summary> /// Find data in database /// </summary> /// <returns></returns> public List <Country> Find(CountryCriteria countryCriteria = null) { List <Country> resultList = null; TableQuery <CountryRow> rowList = _dbContext.Table <CountryRow>(); CriteriaTransformer.CompleteQuery(ref rowList, countryCriteria); if (rowList != null && rowList.Count() > 0) { resultList = new List <Country>(); foreach (var row in rowList) { resultList.Add(CountryTransformer.ToBean(row)); } } return(resultList); }
/// <summary> /// Find body exercises /// </summary> /// <returns></returns> public List <BodyExercise> Find(BodyExerciseCriteria bodyExerciseCriteria = null) { List <BodyExercise> resultList = null; TableQuery <BodyExerciseRow> muscularGroupRowList = _dbContext.Table <BodyExerciseRow>(); CriteriaTransformer.CompleteQuery(ref muscularGroupRowList, bodyExerciseCriteria); if (muscularGroupRowList != null && muscularGroupRowList.Count() > 0) { resultList = new List <BodyExercise>(); foreach (var muscularGroupRow in muscularGroupRowList) { resultList.Add(BodyExerciseTransformer.ToBean(muscularGroupRow)); } } return(resultList); }
/// <summary> /// Find data in database /// </summary> /// <returns></returns> public List <UserInfo> Find(UserInfoCriteria userInfoCriteria = null) { List <UserInfo> resultList = null; TableQuery <UserInfoRow> rowList = _dbContext.Table <UserInfoRow>(); CriteriaTransformer.CompleteQuery(ref rowList, userInfoCriteria); if (rowList != null && rowList.Count() > 0) { resultList = new List <UserInfo>(); foreach (var userInfoRow in rowList) { resultList.Add(UserInfoTransformer.ToBean(userInfoRow)); } } return(resultList); }
/// <summary> /// /// </summary> /// <returns></returns> public List <MuscularGroup> Find(MuscularGroupCriteria muscularGroupCriteria = null) { List <MuscularGroup> resultList = null; TableQuery <MuscularGroupRow> muscularGroupRowList = _dbContext.Table <MuscularGroupRow>(); CriteriaTransformer.CompleteQuery(ref muscularGroupRowList, muscularGroupCriteria); if (muscularGroupRowList != null && muscularGroupRowList.Count() > 0) { resultList = new List <MuscularGroup>(); foreach (var muscularGroupRow in muscularGroupRowList) { resultList.Add(MuscularGroupTransformer.ToBean(muscularGroupRow)); } } return(resultList); }
public static void SetSettings() //Access database and set settings values from accessed data { string output = ""; output += "\nGet query example: "; string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "ormdata.db3"); SQLiteConnection db = new SQLiteConnection(dbPath); TableQuery <Database> table = db.Table <Database>(); try { if (table.Count() > 0) { foreach (var s in table) { Console.WriteLine("Viberate: {0} High Score: {1} Selected Month: {2} Help: {3}", s.Stored_Viberate, s.Stored_HighScore, s.Stored_SelectedMonth, s.Stored_Help); settings.SelectedMonth = s.Stored_SelectedMonth; settings.Viberate = s.Stored_Viberate; settings.HighScore = s.Stored_HighScore; settings.Help = s.Stored_Help; Console.WriteLine("Accessing entry"); } } else { Console.WriteLine("Add new entry"); settings.SelectedMonth = 0; settings.Viberate = true; settings.HighScore = 0; settings.Help = true; Add(); } } catch { Console.WriteLine("catch add new entry"); settings.SelectedMonth = 0; settings.Viberate = true; settings.HighScore = 0; settings.Help = true; Add(); } }
public void InsertNewElement(List <JSON.Weather> p_List) { TableQuery <Table> DateOrder = BDDConnection.Table <Table>().OrderByDescending(t => t.Date); DateTime RecentDate = new DateTime(); if (DateOrder.Count() != 0) { RecentDate = DateOrder.ElementAt(0).Date; } int indiceInsert = 0; if (DateTime.Compare(RecentDate, DateTime.Parse(p_List[indiceInsert].date.Heure)) < 0) { ClearTable(); InsertList(p_List); } else { while (DateTime.Compare(RecentDate, DateTime.Parse(p_List[indiceInsert].date.Heure)) > 0) { indiceInsert++; } List <Table> temp = new List <Table>(); Table tmp; foreach (Weather wth in p_List) { tmp = wth; temp.Add(tmp); } for (int i = indiceInsert; i < temp.Count - 1; i++) { try { Insert(temp[i]); } catch (Exception e) { Log.Info("BDD Weather APP", "Error when trying to insert the new elements of weather in the BDD " + e.ToString()); } } } }
public List <Promocion> cargarPromociones() { List <Promocion> promos = new List <Promocion>(); try { TableQuery <Promocion> listaPromos = baseDatos.Table <Promocion>(); for (int i = 0; i < listaPromos.Count(); i++) { promos.Add(listaPromos.ElementAt(i)); } } catch (Exception e) { } return(promos); }
/// <summary> /// Find datas /// </summary> /// <returns></returns> public List <TrainingDay> Find(TrainingDayCriteria trainingDayCriteria = null) { List <TrainingDay> resultList = null; TableQuery <TrainingDayRow> rowList = _dbContext.Table <TrainingDayRow>(); CriteriaTransformer.CompleteQuery(ref rowList, trainingDayCriteria); rowList = rowList.OrderBy(t => t.DayOfWeek).OrderBy(t => t.BeginHour); if (rowList != null && rowList.Count() > 0) { resultList = new List <TrainingDay>(); foreach (var trainingJournalDayRow in rowList) { resultList.Add(TrainingDayTransformer.ToBean(trainingJournalDayRow)); } } return(resultList); }
/// <summary> /// Find datas /// </summary> /// <returns></returns> public List <TrainingExercise> Find(TrainingExerciseCriteria trainingExerciseCriteria = null) { List <TrainingExercise> resultList = null; TableQuery <TrainingExerciseRow> rowList = _dbContext.Table <TrainingExerciseRow>(); CriteriaTransformer.CompleteQuery(ref rowList, trainingExerciseCriteria); rowList = rowList.OrderBy(t => t.Id); if (rowList != null && rowList.Count() > 0) { resultList = new List <TrainingExercise>(); foreach (var row in rowList) { resultList.Add(GetBean(row)); } } return(resultList); }
/// <summary> /// Find datas /// </summary> /// <returns></returns> public List <TrainingWeek> Find(TrainingWeekCriteria trainingWeekCriteria = null) { List <TrainingWeek> resultList = null; TableQuery <TrainingWeekRow> rowList = _dbContext.Table <TrainingWeekRow>(); CriteriaTransformer.CompleteQuery(ref rowList, trainingWeekCriteria); rowList = rowList.OrderBy(t => t.UserId).OrderByDescending(t => t.Year).ThenByDescending(t => t.WeekOfYear); if (rowList != null && rowList.Count() > 0) { resultList = new List <TrainingWeek>(); foreach (var trainingJournalRow in rowList) { resultList.Add(TrainingWeekTransformer.ToBean(trainingJournalRow)); } } return(resultList); }
public void CanHaveSubtractInWhereClause() { int n = 20; IEnumerable <TestObjInt> cq = from i in Enumerable.Range(1, n) select new TestObjInt() { Data = i, }; var db = new TestDb(TestPath.CreateTemporaryDatabase()); db.InsertAll(cq); TableQuery <TestObjInt> results = db.Table <TestObjInt>().Where(o => o.Data - 10 >= 0); Assert.AreEqual(results.Count(), 11); Assert.AreEqual(results.OrderBy(o => o.Data).FirstOrDefault().Data, 10); }
public void AddForStringsMeansConcatenate() { int n = 20; IEnumerable <TestObjString> cq = from i in Enumerable.Range(1, n) select new TestObjString() { Data = i.ToString(), }; var db = new TestDb(TestPath.CreateTemporaryDatabase()); db.InsertAll(cq); TableQuery <TestObjString> results = db.Table <TestObjString>().Where(o => o.Data + "1" == "11"); Assert.AreEqual(1, results.Count()); Assert.AreEqual("1", results.OrderBy(o => o.Data).FirstOrDefault().Data); }
public List <UserApp> cargarUsuarios() { List <UserApp> usuarios = new List <UserApp>(); try { TableQuery <UserApp> tablaUsuarios = baseDatos.Table <UserApp>(); for (int i = 0; i < tablaUsuarios.Count(); i++) { usuarios.Add(tablaUsuarios.ElementAt(i)); } } catch (Exception e) { Console.WriteLine("Error: " + e); } return(usuarios); }
public List <TweetProgramado> cargarTweetProgramado() { List <TweetProgramado> tweetsProg = new List <TweetProgramado>(); try { TableQuery <TweetProgramado> tweets = baseDatos.Table <TweetProgramado>(); for (int i = 0; i < tweets.Count(); i++) { tweetsProg.Add(tweets.ElementAt(i)); } } catch (Exception e) { Console.WriteLine("Error: " + e); } return(tweetsProg); }