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


C# IDbConnection.Delete方法代码示例

本文整理汇总了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");
 }
开发者ID:armory09,项目名称:ConstosoUniversityMVCwithDapper,代码行数:14,代码来源:StudentController.cs

示例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;
            };
        }
开发者ID:JonghoL,项目名称:DasStaus,代码行数:68,代码来源:DasModule.cs

示例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");
 }
开发者ID:armory09,项目名称:ConstosoUniversityMVCwithDapper,代码行数:22,代码来源:InstructorController.cs


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