本文整理汇总了C#中IDbConnection.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection.Delete方法的具体用法?C# IDbConnection.Delete怎么用?C# IDbConnection.Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDbConnection
的用法示例。
在下文中一共展示了IDbConnection.Delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public ActionResult Delete(int id)
{
try
{
_connection = Connect.Open();
var studentLst = _connection.Get<Student>(id);
_connection.Delete(studentLst);
}
catch(DataException)
{
return RedirectToAction("Delete", new {id, saveChangesError = true});
}
return RedirectToAction("Index");
}
示例2: DasModule
public DasModule()
{
Get["/", runAsync: true] = async (_, token) =>
{
var model = new MainModel()
{
Title = Utilities.GetTitle(),
SubTitle = Utilities.GetSubTitle(),
TwitterWidgetSrc = Utilities.GetWidgetSrc(),
Users = GetList().Where(u=> u.Status != "Offline").Select(u => new DasUserEx(u)).OrderByDescending(o => o.Date)
};
return View["index.sshtml", model];
};
Get["/test"] = _ =>
{
return "Hello World";
};
Get["/new"] = _ =>
{
int ret = default(int);
using (_connection = Utilities.GetOpenConnection())
{
_connection.DropAndCreateTable<DasUser>();
_connection.Close();
}
return ret;
};
Get["/sample"] = _ =>
{
dynamic ret;
using (_connection = Utilities.GetOpenConnection())
{
ret = _connection.Insert(
new DasUser
{
TwitterId = 123456789,
Status = "Online",
Name = "테스터",
Message = "메세지메세지",
Date = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, DasModule.koreaTZI)
});
_connection.Close();
}
return ret;
};
Get["/delete"] = _ =>
{
int ret = default(int);
using (_connection = Utilities.GetOpenConnection())
{
var results = _connection.Where<DasUser>(new { TwitterId = 123456789 });
foreach (var result in results)
{
ret = _connection.Delete(result);
}
_connection.Close();
}
return ret;
};
}
示例3: Delete
public ActionResult Delete(int id)
{
try
{
_connection = Connect.Open();
var courseInstuctor = _connection.GetList<CourseInstructor>(id);
foreach (var course in courseInstuctor)
{
var condition = new PredicateGroup {Operator = GroupOperator.And, Predicates = new List<IPredicate>()};
condition.Predicates.Add(Predicates.Field<CourseInstructor>(s=>s.CourseId, Operator.Eq, course.CourseId));
condition.Predicates.Add(Predicates.Field<CourseInstructor>(s=>s.InstructorId, Operator.Eq, id));
_connection.Delete<CourseInstructor>(condition);
}
_connection.Delete<OfficeAssignment>(Predicates.Field<OfficeAssignment>(s => s.InstructorId, Operator.Eq, id));
_connection.Delete<Instructor>(Predicates.Field<Instructor>(s => s.InstructorId, Operator.Eq, id));
}
catch(DataException)
{
return RedirectToAction("Delete", new {id, saveChangesError = true});
}
return RedirectToAction("Index");
}