本文整理汇总了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();
}
}
示例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);
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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);
}
示例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);
}
示例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;
}
}