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


C# IDbConnection.Get方法代码示例

本文整理汇总了C#中IDbConnection.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection.Get方法的具体用法?C# IDbConnection.Get怎么用?C# IDbConnection.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDbConnection的用法示例。


在下文中一共展示了IDbConnection.Get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Get

 public GroupSaleVehicle Get(int id, IDbConnection connection)
 {
     return connection.Get<GroupSaleVehicle>(id);
 }
开发者ID:coderasm,项目名称:ABSBuybackMVCWebAPI,代码行数:4,代码来源:GSVRepository.cs

示例3: EditPost

        public ActionResult EditPost(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            _connection = Connect.Open();
            var studentToUpdate = _connection.Get<Student>(id);
            if (TryUpdateModel(studentToUpdate, "", new[]
            {
                    "LastName", "FirstMidName", "EnrollmentDate"
                }))
            {
                try
                {
                    _connection.Update(studentToUpdate);
                    return RedirectToAction("Index");
                }
                catch (DataException)
                {
                    ModelState.AddModelError("","Unable to save changes. Try again, and if the problem persist please see your system administrator");
                }
            }

            return View(studentToUpdate);
        }
开发者ID:armory09,项目名称:ConstosoUniversityMVCwithDapper,代码行数:26,代码来源:StudentController.cs

示例4: Edit

 // GET: Student/Edit/5
 public ActionResult Edit(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     _connection = Connect.Open();
     var studentLst = _connection.Get<Student>(id);
     if (studentLst == null)
     {
         return HttpNotFound("Student not found");
     }
     return View(studentLst);
 }
开发者ID:armory09,项目名称:ConstosoUniversityMVCwithDapper,代码行数:15,代码来源:StudentController.cs

示例5: Print

 private static void Print(IDbConnection connection, Guid id)
 {
     var inserted = connection.Get<GrandParent>(new { Id = id });
     Console.WriteLine("Date: {0}", inserted.Name);
 }
开发者ID:brettveenstra,项目名称:ExampleCode,代码行数:5,代码来源:Program.cs

示例6: EditPost

        public ActionResult EditPost(int? id, string[] selectedCourses)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            _connection = Connect.Open();
            var instructorToUpdate = GetInstructor(id);

            var courseLst = GetInstructorCourse(id);

            courseLst.ForEach(instructorToUpdate.AddCourse);

            if (TryUpdateModel(instructorToUpdate, "",
                new[] { "LastName", "FirstMidName", "HireDate", "OfficeAssignment" }))
            {
                try
                {
                    instructorToUpdate.OfficeAssignment.InstructorId = instructorToUpdate.InstructorId;

                    var checkOffice = _connection.Get<OfficeAssignment>(id);

                    if (checkOffice != null)
                    {
                        //update OfficeAssignment
                        _connection.Update(instructorToUpdate.OfficeAssignment);
                    }
                    else
                    {
                        //insert OfficeAssignment
                        _connection.Insert(instructorToUpdate.OfficeAssignment);

                    }

                    UpdateInstructorCourses(selectedCourses, instructorToUpdate);
                    _connection.Update(instructorToUpdate);
                    return RedirectToAction("Index");
                }
                catch (RetryLimitExceededException)
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists please see the administrator.");
                }

            }
            PopulateAssignedCourseData(instructorToUpdate);
            return View(instructorToUpdate);
        }
开发者ID:armory09,项目名称:ConstosoUniversityMVCwithDapper,代码行数:47,代码来源:InstructorController.cs


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