當前位置: 首頁>>代碼示例>>C#>>正文


C# Database.Delete方法代碼示例

本文整理匯總了C#中PetaPoco.Database.Delete方法的典型用法代碼示例。如果您正苦於以下問題:C# Database.Delete方法的具體用法?C# Database.Delete怎麽用?C# Database.Delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PetaPoco.Database的用法示例。


在下文中一共展示了Database.Delete方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: btnReView_ItemClick

 void btnReView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     var et = gcloginfail.GetFocusedDataSource<t_loginfail>();
     if (null == et)
         return;
     if (MsgBox.ShowYesNoMessage(null,
         string.Format("確定要將 {0} MAC:{1} 審核通過嗎?", et.UserName, et.LoginMAC)) == System.Windows.Forms.DialogResult.No)
         return;
     var usr = GetCurUser<t_user>();
     using (var db = new Database()) {
         try {
             db.BeginTransaction();
             db.Delete("t_loginfail", "Id", et, et.Id);
             db.Execute(sql_addmac, et.LoginMAC, usr.UserName, usr.Guid);
             db.CompleteTransaction();
         } catch (Exception) {
             db.AbortTransaction();
     #if DEBUG
             throw;
     #endif
         }
     }
     using (var db = new Database()) {
         var etfail = db.Fetch<t_loginfail>("select * from t_loginfail");
         gcloginfail.DataSource = etfail;
         gcloginfail.RefreshDataSource();
         var etmac = db.Fetch<t_loginfail>("select * from t_mac");
         gcMac.DataSource = etmac;
         gcMac.RefreshDataSource();
     }
 }
開發者ID:MasterGao,項目名稱:DevWinFormFrame,代碼行數:31,代碼來源:MainView.cs

示例2: Delete

        public void Delete(long id)
        {
            if (id <= 0)
            {
                return;
            }

            ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.Account), "DELETE");
            policy.Authorize();

            if (!policy.IsAuthorized)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            try
            {
                using (Database db = new Database(Factory.GetConnectionString(), "Npgsql"))
                {
                    db.Delete("core.accounts", "account_id", null, id);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
開發者ID:JonathanValle,項目名稱:mixerp,代碼行數:27,代碼來源:Core.cs

示例3: DeleteEntities

        protected override void DeleteEntities(List<Entity> entities)
        {
            using (var database = new Database("SQLiteTest"))
            {
                using (var transaction = database.GetTransaction())
                {
                    entities.ForEach(entity => database.Delete(entity));

                    transaction.Complete();
                }
            }
        }
開發者ID:TrevorPilley,項目名稱:MicroORM.Benchmark,代碼行數:12,代碼來源:PetaPocoBenchmark.cs

示例4: RecreateFilters

        public void RecreateFilters(string objectName, string filterName, List<MixERP.Net.Entities.Core.Filter> filters)
        {
            if (!this.SkipValidation)
            {
                if (!this.Validated)
                {
                    this.Validate(AccessTypeEnum.Create, this._LoginId, this._Catalog, false);
                }

                if (!this.HasAccess)
                {
                    Log.Information("Access to add entity \"Filter\" was denied to the user with Login ID {LoginId}. {filters}", this._LoginId, filters);
                    throw new UnauthorizedException("Access is denied.");
                }
            }

            using (Database db = new Database(Factory.GetConnectionString(this._Catalog), Factory.ProviderName))
            {
                using (Transaction transaction = db.GetTransaction())
                {

                    var toDelete = this.GetWhere(1, new List<EntityParser.Filter>
                        {
                            new EntityParser.Filter { ColumnName = "object_name", FilterCondition = (int) FilterCondition.IsEqualTo, FilterValue = objectName },
                            new EntityParser.Filter { ColumnName = "filter_name", FilterCondition = (int) FilterCondition.IsEqualTo, FilterValue = filterName }
                        });

                    foreach (var filter in toDelete)
                    {
                        db.Delete(filter);
                    }

                    foreach (var filter in filters)
                    {
                        filter.AuditUserId = this._UserId;
                        filter.AuditTs = System.DateTime.UtcNow;

                        db.Insert(filter);
                    }

                    transaction.Complete();
                }
            }
        }
開發者ID:pplatek,項目名稱:mixerp,代碼行數:44,代碼來源:Filter.cs

示例5: btnDel_Click

 private void btnDel_Click(object sender, EventArgs e)
 {
     var et = gvItem.GetFocusedDataSource<UltraDbEntity.T_ERP_Item>();
     var dt = gvprice.GetFocusedDataSource<UltraDbEntity.T_ERP_ProducePrice>();
     if (null == dt) return;
     if (null == et) return;
     if (MsgBox.ShowYesNoMessage(string.Empty, "確定要刪除?") == System.Windows.Forms.DialogResult.No)
         return;
     dt.IsDel = true;
     using (var db = new Database(this.ConnString))
     {
         db.Delete(dt);
     }
     gvItem_FocusedRowChanged(null, null);
 }
開發者ID:ZixiangBoy,項目名稱:FAS,代碼行數:15,代碼來源:ItemPrice.cs

示例6: TestDeleteOperation

 private static void TestDeleteOperation(Database db, Container newContainer)
 {
     Console.WriteLine("poistetaan: {0} - {1}, {2}", newContainer.ContainerId, newContainer.Modificator, newContainer.ModificationDate);
     db.Delete("Container", "ContainerId", newContainer);
     Console.WriteLine("poistettu: {0} - {1}, {2}", newContainer.ContainerId, newContainer.Modificator, newContainer.ModificationDate);
 }
開發者ID:juarola,項目名稱:PetaPocoTest,代碼行數:6,代碼來源:Program.cs

示例7: btnRemove_ItemClick

 void btnRemove_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     var et = gcMac.GetFocusedDataSource<t_mac>();
     if (null == et)
         return;
     if (MsgBox.ShowYesNoMessage(null, "確定要刪除嗎?") == System.Windows.Forms.DialogResult.No)
         return;
     using (var db = new Database()) {
         db.Delete(et);
     }
     using (var db = new Database()) {
         var etmac = db.Fetch<t_mac>("select * from t_mac");
         gcMac.DataSource = etmac;
     }
 }
開發者ID:MasterGao,項目名稱:DevWinFormFrame,代碼行數:15,代碼來源:MainView.cs


注:本文中的PetaPoco.Database.Delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。