当前位置: 首页>>代码示例>>C#>>正文


C# SQLiteConnection.GetChildren方法代码示例

本文整理汇总了C#中SQLiteConnection.GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.GetChildren方法的具体用法?C# SQLiteConnection.GetChildren怎么用?C# SQLiteConnection.GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLiteConnection的用法示例。


在下文中一共展示了SQLiteConnection.GetChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateTestData

		static void CreateTestData (SQLiteConnection db)
		{
			var js = new MeasurementSubjectModel () { Name = "JS"};
			if (db.Table<MeasurementSubjectModel> ().Count (c => c.Name == "JS") == 0) {
				db.Insert (js);
			} else {
				js = db.Table<MeasurementSubjectModel> ().Where (w => w.Name == "JS").FirstOrDefault ();
			}

			var jsProfile = new ProfileModel () { MeasurementSubjectId = js.Id};

			var jp = db.Query<ProfileModel> ("SELECT P.* FROM ProfileModel as P JOIN MeasurementSubjectModel AS s ON p.MeasurementSubjectId == s.Id WHERE s.Name == ?", "JS");
			if(jp.Count == 0) {
				db.Insert (jsProfile);

				var v = new ProfileMeasurementDefinitionModel () {
					MeasurementFrequencyId = 3,
					MeasurementDefinitionId = 1,
					ProfileId = jsProfile.Id,
					MeasureTypeId = 2
				};

				db.Insert (v);

				db.Insert(new ProfileMeasurementDefinitionModel () {
					MeasurementFrequencyId = 4 ,
					MeasurementDefinitionId = 2 ,
					ProfileId = jsProfile.Id,
					MeasureTypeId = 7
				});
				db.Insert (new ProfileMeasurementDefinitionModel () {
					MeasurementFrequencyId = 3 ,
					MeasurementDefinitionId = 3 ,
					ProfileId = jsProfile.Id,
					MeasureTypeId = 2

				});


			} else {
				jsProfile = jp.FirstOrDefault ();
				db.GetChildren (jsProfile, true);
			}

			var stella = new MeasurementSubjectModel () { Name = "Stella" };
			if (db.Table<MeasurementSubjectModel> ().Count (c => c.Name == "Stella") == 0) {
				db.Insert (stella);
			}else {
				stella = db.Table<MeasurementSubjectModel> ().Where (w => w.Name == "Stella").FirstOrDefault ();
			}

			var stellaProfile = new ProfileModel () { MeasurementSubjectId = stella.Id };

			var sp = db.Query<ProfileModel> ("SELECT P.* FROM ProfileModel as P JOIN MeasurementSubjectModel AS s ON p.MeasurementSubjectId == s.Id WHERE s.Name == ?", "Stella");
			if(sp.Count == 0) {
				db.Insert (stellaProfile);

				var v = new ProfileMeasurementDefinitionModel () {
					MeasurementFrequencyId = 3,
					MeasurementDefinitionId = 1,
					ProfileId = stellaProfile.Id,
					MeasureTypeId = 2
				};

				var c = db.Insert (v);

				db.Insert(new ProfileMeasurementDefinitionModel () {
					MeasurementFrequencyId = 4 ,
					MeasurementDefinitionId = 2 ,
					ProfileId = stellaProfile.Id,
					MeasureTypeId = 7
				});
				db.Insert (new ProfileMeasurementDefinitionModel () {
					MeasurementFrequencyId = 3 ,
					MeasurementDefinitionId = 3 ,
					ProfileId = stellaProfile.Id,
					MeasureTypeId = 2

				});

			} else {
				stellaProfile = sp.FirstOrDefault ();
				db.GetChildren (stellaProfile, true);
			}


			var isabelle = new MeasurementSubjectModel () { Name = "Isabelle" };
			if (db.Table<MeasurementSubjectModel> ().Count (c => c.Name == "Isabelle") == 0) {
				db.Insert (isabelle);
			}else {
				isabelle = db.Table<MeasurementSubjectModel> ().Where (w => w.Name == "Isabelle").FirstOrDefault ();
			}

			var jsBloodPressure = new MeasurementInstanceModel () {DateRecorded = DateTime.Now, MeasurementSubjectId = js.Id, MeasurementDefinitionId = 1 };
			var jsBloodPressure2 = new MeasurementInstanceModel () {DateRecorded = DateTime.Now.AddDays(-1), MeasurementSubjectId = js.Id, MeasurementDefinitionId = 1 };
			var jsBloodPressure3 = new MeasurementInstanceModel () {DateRecorded = DateTime.Now.AddDays(-2), MeasurementSubjectId = js.Id, MeasurementDefinitionId = 1 };

			if (db.Table<MeasurementInstanceModel> ().Count (w => w.MeasurementSubjectId == js.Id && w.MeasurementDefinitionId == 1) == 0) {
				db.Insert (jsBloodPressure);
				db.Insert (new MeasurementGroupInstanceModel () { MeasurementInstanceId = jsBloodPressure.Id, MeasurementGroupDefinitionId = 1, UnitId = 1, Value = 120 });
//.........这里部分代码省略.........
开发者ID:jscote,项目名称:Meezure,代码行数:101,代码来源:Initialization.cs


注:本文中的SQLiteConnection.GetChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。