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


C# DbManager.ExecuteNonQuery方法代码示例

本文整理汇总了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));
                    }
                }
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:54,代码来源:ResourceData.cs

示例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));
                    }
                }
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:54,代码来源:ResourceData.cs

示例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");
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:12,代码来源:DataTest.cs

示例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);
            }
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:27,代码来源:MessagesRepository.cs

示例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);
            }
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:25,代码来源:FeedAggregateDataProvider.cs

示例6: Delete

 public void Delete(int id)
 {
     using (var db = new DbManager(DatabaseId))
     {
         db.ExecuteNonQuery(Delete(TemplatesTable).Where("id", id));
     }
 }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:7,代码来源:TemplateDao.cs

示例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));
     }
 }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:20,代码来源:DbTokenManager.cs

示例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));
     }
 }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:7,代码来源:DbProvider.cs

示例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();
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:47,代码来源:FeedAggregateDataProvider.cs

示例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();
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:45,代码来源:SharePointSecurityDao.cs

示例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);
     }
 }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:9,代码来源:GetResource.cs

示例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);
     }
 }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:9,代码来源:ResourceData.cs

示例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)));
     }
 }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:10,代码来源:CommonDbWrapper.cs

示例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));
            }
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:12,代码来源:UsageData.cs

示例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);
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:13,代码来源:ParticipantDao.cs


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