本文整理汇总了C#中DbManager.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# DbManager.ExecuteNonQuery方法的具体用法?C# DbManager.ExecuteNonQuery怎么用?C# DbManager.ExecuteNonQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbManager
的用法示例。
在下文中一共展示了DbManager.ExecuteNonQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddResource
public static void AddResource(string cultureTitle, string resType, DateTime date, ResWord word, bool isConsole, string authorLogin)
{
using (var db = new DbManager("tmresource"))
{
var resData = db.ExecuteScalar<string>(GetQuery("res_data", cultureTitle, word));
var resReserve = db.ExecuteScalar<string>(GetQuery("res_reserve", cultureTitle, word));
if (string.IsNullOrEmpty(resData))
{
db.ExecuteNonQuery(Insert("res_data", cultureTitle, word)
.InColumnValue("resourceType", resType)
.InColumnValue("timechanges", date)
.InColumnValue("flag", 2)
.InColumnValue("authorLogin", authorLogin));
if (isConsole) db.ExecuteNonQuery(Insert("res_reserve", cultureTitle, word));
}
else
{
var isChangeResData = resData != word.ValueFrom;
var isChangeResReserve = resReserve != word.ValueFrom;
if ((isConsole && isChangeResData && isChangeResReserve) || !isConsole)
{
if (cultureTitle == "Neutral")
{
var update = new SqlUpdate("res_data")
.Set("flag", 3)
.Where("fileID", word.ResFile.FileID)
.Where("title", word.Title);
db.ExecuteNonQuery(update);
}
db.ExecuteNonQuery(Insert("res_data", cultureTitle, word)
.InColumnValue("resourceType", resType)
.InColumnValue("timechanges", date)
.InColumnValue("flag", 2)
.InColumnValue("authorLogin", authorLogin));
if (isConsole) db.ExecuteNonQuery(Update("res_reserve", cultureTitle, word));
}
else if (isConsole && isChangeResData && !isChangeResReserve)
{
db.ExecuteNonQuery(Update("res_reserve", cultureTitle, word));
}
}
}
}
示例2: AddResource
public static void AddResource(string cultureTitle, string resType, DateTime date, ResWord word, bool isConsole, string authorLogin, bool updateIfExist = true)
{
using (var db = new DbManager("tmresource"))
{
var resData = db.ExecuteScalar<string>(GetQuery("res_data", cultureTitle, word));
var resReserve = db.ExecuteScalar<string>(GetQuery("res_reserve", cultureTitle, word));
//нет ключа
if (string.IsNullOrEmpty(resData))
{
//добавляем в основную таблицу
db.ExecuteNonQuery(Insert("res_data", cultureTitle, word)
.InColumnValue("resourceType", resType)
.InColumnValue("timechanges", date)
.InColumnValue("flag", 2)
.InColumnValue("authorLogin", authorLogin));
//добавляем в резервную таблицу
if (isConsole) db.ExecuteNonQuery(Insert("res_reserve", cultureTitle, word));
}
else if(updateIfExist)
{
var isChangeResData = resData != word.ValueFrom;
var isChangeResReserve = resReserve != word.ValueFrom;
//при работе с консолью изменилось по сравнению с res_data и res_reserve, либо при работе с сайтом изменилось по сравнению с res_reserve
if ((isConsole && isChangeResData && isChangeResReserve) || !isConsole)
{
// изменилась нейтральная культура - выставлен флаг у всех ключей из выбранного файла с выбранным title
if (cultureTitle == "Neutral")
{
var update = new SqlUpdate("res_data")
.Set("flag", 3)
.Where("fileID", word.ResFile.FileID)
.Where("title", word.Title);
db.ExecuteNonQuery(update);
}
// изменилась не нейтральная культура
db.ExecuteNonQuery(Insert("res_data", cultureTitle, word)
.InColumnValue("resourceType", resType)
.InColumnValue("timechanges", date)
.InColumnValue("flag", 2)
.InColumnValue("authorLogin", authorLogin));
if (isConsole) db.ExecuteNonQuery(Update("res_reserve", cultureTitle, word));
}
else if (isChangeResData)
{
db.ExecuteNonQuery(Update("res_reserve", cultureTitle, word));
}
}
}
}
示例3: DbTransactionTest
public void DbTransactionTest()
{
var dbManager = new DbManager(dbId);
dbManager.ExecuteNonQuery("create table if not exists a(c1 TEXT)", null);
var tx = dbManager.BeginTransaction();
dbManager.ExecuteNonQuery("insert into a(c1) values (?)", "s");
dbManager.ExecuteNonQuery("insert into a(c1) values (?)", "s2");
tx.Dispose();
dbManager.ExecuteNonQuery("insert into a(c1) values (?)", "s3");
}
示例4: AddLoginEvent
private static void AddLoginEvent(EventMessage message)
{
using (var db = new DbManager(messagesDbId))
{
var i = new SqlInsert(loginEventsTable)
.InColumnValue("ip", message.IP)
.InColumnValue("login", message.Initiator)
.InColumnValue("browser", message.Browser)
.InColumnValue("mobile", message.Mobile)
.InColumnValue("platform", message.Platform)
.InColumnValue("date", message.Date)
.InColumnValue("tenant_id", message.TenantId)
.InColumnValue("user_id", message.UserId)
.InColumnValue("page", message.Page)
.InColumnValue("action", message.Action);
if (message.Description != null && message.Description.Any())
{
i = i.InColumnValue("description", JsonConvert.SerializeObject(message.Description, new JsonSerializerSettings
{
DateTimeZoneHandling = DateTimeZoneHandling.Utc
}));
}
db.ExecuteNonQuery(i);
}
}
示例5: SaveFeeds
public static void SaveFeeds(IEnumerable<FeedRow> feeds, string key, DateTime value)
{
using (var db = new DbManager(Constants.FeedDbId))
{
db.ExecuteNonQuery(new SqlInsert("feed_last", true).InColumnValue("last_key", key).InColumnValue("last_date", value));
}
const int feedsPortionSize = 1000;
var aggregatedDate = DateTime.UtcNow;
var feedsPortion = new List<FeedRow>();
foreach (var feed in feeds)
{
feedsPortion.Add(feed);
if (feedsPortion.Sum(f => f.Users.Count) <= feedsPortionSize) continue;
SaveFeedsPortion(feedsPortion, aggregatedDate);
feedsPortion.Clear();
}
if (feedsPortion.Any())
{
SaveFeedsPortion(feedsPortion, aggregatedDate);
}
}
示例6: Delete
public void Delete(int id)
{
using (var db = new DbManager(DatabaseId))
{
db.ExecuteNonQuery(Delete(TemplatesTable).Where("id", id));
}
}
示例7: StoreNewRequestToken
/// <summary>
/// Stores a newly generated unauthorized request token, secret, and optional
/// application-specific parameters for later recall.
/// </summary>
/// <param name="request">The request message that resulted in the generation of a new unauthorized request token.</param>
/// <param name="response">The response message that includes the unauthorized request token.</param>
/// <exception cref="ArgumentException">Thrown if the consumer key is not registered, or a required parameter was not found in the parameters collection.</exception>
/// <remarks>
/// Request tokens stored by this method SHOULD NOT associate any user account with this token.
/// It usually opens up security holes in your application to do so. Instead, you associate a user
/// account with access tokens (not request tokens) in the <see cref="ExpireRequestTokenAndStoreNewAccessToken"/>
/// method.
/// </remarks>
public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response)
{
using (var db = new DbManager(_dbId))
{
db.ExecuteNonQuery(new SqlInsert(TOKEN_TABLE, true).InColumnValue("token", response.Token).InColumnValue("token_secret", response.TokenSecret).InColumnValue("request_token",true));
}
}
示例8: UpdateLastDeltaIndexDate
public static void UpdateLastDeltaIndexDate(ModuleInfo module)
{
using (var db = new DbManager("default"))
{
db.ExecuteNonQuery(new SqlInsert("webstudio_index", true).InColumnValue("index_name", module.Delta));
}
}
示例9: SaveFeeds
public static void SaveFeeds(IEnumerable<FeedRow> feeds, string key, DateTime value)
{
using (var db = new DbManager(Constants.FeedDbId))
using (var tx = db.BeginTransaction())
{
db.ExecuteNonQuery(new SqlInsert("feed_last", true).InColumnValue("last_key", key).InColumnValue("last_date", value));
var now = DateTime.UtcNow;
foreach (var f in feeds)
{
if (0 >= f.Users.Count) continue;
var i = new SqlInsert("feed_aggregate", true)
.InColumnValue("id", f.Id)
.InColumnValue("tenant", f.Tenant)
.InColumnValue("product", f.ProductId)
.InColumnValue("module", f.ModuleId)
.InColumnValue("author", f.AuthorId)
.InColumnValue("group_id", f.GroupId)
.InColumnValue("created_date", f.CreatedDate)
.InColumnValue("json", f.Json)
.InColumnValue("keywords", f.Keywords)
.InColumnValue("aggregated_date", now);
db.ExecuteNonQuery(i);
if (f.ClearRightsBeforeInsert)
{
db.ExecuteNonQuery(
new SqlDelete("feed_users")
.Where("feed_id", f.Id)
);
}
foreach (var u in f.Users)
{
db.ExecuteNonQuery(
new SqlInsert("feed_users", true)
.InColumnValue("feed_id", f.Id)
.InColumnValue("user_id", u.ToString())
);
}
}
tx.Commit();
}
}
示例10: SetShare
public void SetShare(FileShareRecord r)
{
using (var dbManager = new DbManager(FileConstant.DatabaseId))
using (var tx = dbManager.BeginTransaction())
{
if (r.Share == FileShare.None)
{
if (r.EntryType == FileEntryType.Folder)
{
var entryIDs = dbManager.ExecuteList(Query("files_thirdparty_id_mapping")
.Select("hash_id")
.Where(Exp.Like("id", r.EntryId.ToString(), SqlLike.StartWith)))
.ConvertAll(x => x[0]);
dbManager.ExecuteNonQuery(Delete("files_security")
.Where(Exp.In("entry_id", entryIDs) &
Exp.Eq("subject", r.Subject.ToString())));
}
else
{
var d2 = Delete("files_security")
.Where(Exp.Eq("entry_id", MappingID(r.EntryId, true)))
.Where("entry_type", (int) FileEntryType.File)
.Where("subject", r.Subject.ToString());
dbManager.ExecuteNonQuery(d2);
}
}
else
{
var i = new SqlInsert("files_security", true)
.InColumnValue("tenant_id", r.Tenant)
.InColumnValue("entry_id", MappingID(r.EntryId, true))
.InColumnValue("entry_type", (int) r.EntryType)
.InColumnValue("subject", r.Subject.ToString())
.InColumnValue("owner", r.Owner.ToString())
.InColumnValue("security", (int) r.Share)
.InColumnValue("timestamp", DateTime.UtcNow);
dbManager.ExecuteNonQuery(i);
}
tx.Commit();
}
}
示例11: SetCultureAvailable
public static void SetCultureAvailable(string title)
{
using (var dbManager = new DbManager("tmresource"))
{
var sql = new SqlUpdate("res_cultures");
sql.Set("available", true).Where("title", title);
dbManager.ExecuteNonQuery(sql);
}
}
示例12: AddCulture
public static void AddCulture(string cultureTitle, string name)
{
using (var dbManager = new DbManager("tmresource"))
{
var sqlInsert = new SqlInsert("res_cultures");
sqlInsert.InColumnValue("title", cultureTitle).InColumnValue("value", name);
dbManager.ExecuteNonQuery(sqlInsert);
}
}
示例13: RemoveOldJtis
public void RemoveOldJtis()
{
var utcNow = DateTime.UtcNow;
_log.DebugFormat("Removing old jtis now={0}", utcNow);
using (var db = new DbManager("webstudio"))
{
db.ExecuteNonQuery(new SqlDelete("sso_tokens")
.Where(Exp.Lt("expirationDate", utcNow)));
}
}
示例14: SetIsMobileAppUser
public static void SetIsMobileAppUser(Guid userId, DeviceType type)
{
string userEmail = CoreContext.UserManager.GetUsers(userId).Email;
using (var db = new DbManager("core"))
{
db.ExecuteNonQuery(
new SqlInsert("push_app_user", replaceExists: true)
.InColumnValue("user_email", userEmail)
.InColumnValue("device_type", (int)type));
}
}
示例15: AddToFollowingProjects
public void AddToFollowingProjects(int project, Guid participant)
{
using (var db = new DbManager(DatabaseId))
{
db.ExecuteNonQuery(
new SqlInsert(FollowingProjectTable, true)
.InColumnValue("project_id", project)
.InColumnValue("participant_id", participant.ToString()));
var projDao = new ProjectDao(db.DatabaseId, Tenant);
projDao.UpdateLastModified(project);
}
}