本文整理汇总了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));
}
}
示例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);
}
}