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


C# TestDb.Update方法代码示例

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


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

示例1: Issue115_MissingPrimaryKey

        public void Issue115_MissingPrimaryKey()
        {
            using (var conn = new TestDb ()) {

                conn.CreateTable<Issue115_MyObject> ();
                conn.InsertAll (from i in Enumerable.Range (0, 10) select new Issue115_MyObject {
                    UniqueId = i.ToString (),
                    OtherValue = (byte)(i * 10),
                });

                var query = conn.Table<Issue115_MyObject> ();
                foreach (var itm in query) {
                    itm.OtherValue++;
                    Assert.AreEqual (1, conn.Update (itm, typeof(Issue115_MyObject)));
                }
            }
        }
开发者ID:robertgreen,项目名称:sqlite-net,代码行数:17,代码来源:CreateTableTest.cs

示例2: NotNullConstraintExceptionListsOffendingColumnsOnUpdate

		public void NotNullConstraintExceptionListsOffendingColumnsOnUpdate ()
		{
			// Skip this test if the Dll doesn't support the extended SQLITE_CONSTRAINT codes

				using (TestDb db = new TestDb ()) {
					db.CreateTable<NotNullNoPK> ();

					try {
						NotNullNoPK obj = new NotNullNoPK () {
							AnotherRequiredStringProp = "Another required string",
							RequiredIntProp = 123,
							RequiredStringProp = "Required string"
						};
						db.Insert (obj);
						obj.RequiredStringProp = null;
						db.Update (obj);
					}
					catch (NotNullConstraintViolationException ex) {
						string expected = "RequiredStringProp";
						string actual = string.Join (", ", ex.Columns.Where (c => !c.IsPK).OrderBy (p => p.PropertyName).Select (c => c.PropertyName));

						Assert.AreEqual (expected, actual, "NotNullConstraintViolationException did not correctly list the columns that violated the constraint");

						return;
					}
					catch (SQLiteException ex) {
						if (SQLite3.LibVersionNumber () < 3007017 && ex.Result == SQLite3.Result.Constraint) {
							Inconclusive ();
							return;
						}
					}
					catch (Exception ex) {
						Assert.Fail ("Expected an exception of type NotNullConstraintViolationException to be thrown. An exception of type {0} was thrown instead.", ex.GetType ().Name);
					}
				Assert.Fail ("Expected an exception of type NotNullConstraintViolationException to be thrown. No exception was thrown.");
			}
		}
开发者ID:89sos98,项目名称:sqlite-net,代码行数:37,代码来源:NotNullAttributeTest.cs

示例3: UpdateWithNullThrowsException

		public void UpdateWithNullThrowsException ()
		{
			using (TestDb db = new TestDb ()) {

				db.CreateTable<NotNullNoPK> ();

				try {
					NotNullNoPK obj = new NotNullNoPK () {
						AnotherRequiredStringProp = "Another required string",
						RequiredIntProp = 123,
						RequiredStringProp = "Required string"
					};
					db.Insert (obj);
					obj.RequiredStringProp = null;
					db.Update (obj);
				}
				catch (NotNullConstraintViolationException) {
					return;
				}
				catch (SQLiteException ex) {
					if (SQLite3.LibVersionNumber () < 3007017 && ex.Result == SQLite3.Result.Constraint) {
						Inconclusive ();
						return;
					}
				}
			}
			Assert.Fail ("Expected an exception of type NotNullConstraintViolationException to be thrown. No exception was thrown.");
		}
开发者ID:89sos98,项目名称:sqlite-net,代码行数:28,代码来源:NotNullAttributeTest.cs


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