当前位置: 首页>>代码示例>>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;未经允许,请勿转载。