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


C# DbManager.InsertWithIdentity方法代码示例

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


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

示例1: SaveEntry

 /// <summary>
 /// Сохраняет запись
 /// </summary>
 /// <param name="entry">Entry.</param>
 protected override void SaveEntry(GuestbookEntry entry)
 {
     using (var db = new DbManager())
     {
         var dbEntry = new DbGuestbookEntry ();
         dbEntry.Message = entry.Message;
         var dbUser = db.GetTable<DbGuestbookUser>().SingleOrDefault (u => u.Name == entry.User);
         if (dbUser == null)
         {
             dbUser = new DbGuestbookUser { Name = entry.User };
             dbUser.Id = Convert.ToInt32(db.InsertWithIdentity (dbUser));
         }
         dbEntry.UserId = dbUser.Id;
         dbEntry.Id = Convert.ToInt32(db.InsertWithIdentity(dbEntry));
     }
 }
开发者ID:nixxa,项目名称:HttpServer,代码行数:20,代码来源:SqlGuestbookApplication.cs

示例2: TestDataTypeTestInsertWithIdentity

		public void TestDataTypeTestInsertWithIdentity()
		{
			using (DbManager db = new DbManager())
			{
				var dt = new DataTypeTest2
				{
					Binary_ = new byte[2] { 1, 2 },
#if !ORACLE
					Boolean_ = true,
					Guid_ = Guid.Empty,
#endif
					Byte_ = 250,
					Bytes_ = new byte[] { 2, 1 },
					DateTime_ = DateTime.Now,
					Decimal_ = 9876543210.0m,
					Double_ = 12345.67890,
					Int16_ = 12345,
					Int32_ = 1234567890,
					Int64_ = 1234567890123456789,
					Money_ = 99876543210.0m,
					Single_ = 1234.0f,
					String_ = "Crazy Frog",

					Char_ = 'F',
					SByte_ = 123,
					//UInt16_   = 65432,
					//UInt32_   = 4000000000,
					//UInt64_   = 12345678901234567890,
#if !SQLCE
					Stream_ = new MemoryStream(5),
					Xml_ = new XmlTextReader(new StringReader("<xml/>")),
					XmlDoc_ = new XmlDocument()
#endif
				};

#if !SQLCE
				string innerxml = "<root><sql id=\"2\">Other Verbiage</sql></root>";
				dt.XmlDoc_.LoadXml(innerxml);
#endif

				var id = Convert.ToInt32(db.InsertWithIdentity(dt));
				var obj = db.GetTable<DataTypeTest2>().Where(_ => _.ID == id).First();

#if !SQLCE
				Assert.AreEqual(innerxml, obj.XmlDoc_.OuterXml);
#endif
				TypeAccessor.WriteConsole(obj);
			}
		}
开发者ID:devmlog,项目名称:bltoolkit,代码行数:49,代码来源:DbManagerTest.cs


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