本文整理汇总了C#中SqlQuery.InsertWithIdentity方法的典型用法代码示例。如果您正苦于以下问题:C# SqlQuery.InsertWithIdentity方法的具体用法?C# SqlQuery.InsertWithIdentity怎么用?C# SqlQuery.InsertWithIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlQuery
的用法示例。
在下文中一共展示了SqlQuery.InsertWithIdentity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertWithIdentityQuery
public void InsertWithIdentityQuery()
{
using (var db = _connectionFactory.CreateDbManager())
{
db.BeginTransaction();
var dataProduct = new DataProductPending
{
Activation = 0,
Commentary = "Valeriu",
DateCreation = DateTime.Now,
DateModification = DateTime.Now,
ProductPending = "Valeriu",
IdUserCreate = 0,
UserProgram = "Valeriu"
};
var query = new SqlQuery(db);
var res = query.InsertWithIdentity(dataProduct);
db.RollbackTransaction();
Console.WriteLine(res);
Console.WriteLine(db.LastQuery);
}
}
示例2: InsertBlob
public void InsertBlob()
{
using (var db = _connectionFactory.CreateDbManager())
{
var sqlQuery = new SqlQuery(db);
var session = new static_nav_session
{
PDF_USER_FILENAME = "PDF_USER_FILENAME",
ID_LOGIN = 1,
STATUS = 3,
PDF_NAME = "COCO",
ID_PDF_RESULT_TYPE = 29,
STATIC_NAV_SESSION = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new DataMedia {Activation = 2, IdLanguageData = 123, IdMedia = 2002, Media = "COCO"}))
};
var sessionId = sqlQuery.InsertWithIdentity(session);
Console.WriteLine(sessionId);
}
}
示例3: InsertDataRadio
public void InsertDataRadio()
{
using (new ExecTimeInfo())
{
using (var db = _connectionFactory.CreateDbManager())
{
db.BeginTransaction();
try
{
var baseData = db.GetTable<DATA_RADIO>()
.Single(d => d.ID_DATA_VERSION == 242000147724 &&
d.IdCobAdvert == 1);
baseData.ID_DATA_RADIO = 0; // Optional
baseData.IdCobAdvert = 3;
baseData.ID_PRODUCT = 180000;
baseData.DATE_MODIFICATION = DateTime.Now;
var query = new SqlQuery(db);
var count = (long) query.InsertWithIdentity(baseData);
Console.WriteLine(count + " -> " + db.LastQuery);
}
catch (Exception ex)
{
throw;
}
finally
{
db.RollbackTransaction();
}
}
}
}
示例4: InsertArtistWithAutoSequence
public void InsertArtistWithAutoSequence()
{
using (var db = _connectionFactory.CreateDbManager())
{
var query = new SqlQuery(db);
var artist = new Label {Name = "TEST", DATE_CREATION = DateTime.Now, DATE_MODIFICATION = DateTime.Now, ACTIVATION = 10, ID_USER_ = 200};
query.InsertWithIdentity(new DataImport
{
Commentary = "aaaa",
DeclaredProduct = "ssfsfsfsfsfsf",
IdMedia = 2024,
DeclaredId = 1
});
}
}