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


C# MySqlConnection.OpenAsync方法代码示例

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


在下文中一共展示了MySqlConnection.OpenAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditStudent

        // GET: AddOfficeVisit
        public async System.Threading.Tasks.Task<ActionResult> EditStudent(string id)
        {

            StudentCollection coll = new StudentCollection();

            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();
                var result = new StudentRepository(connection).GetStudent(id);

                //get all possible values
                var result1 = new StudentRepository(connection).GetStudent(id);
                var result2 = new GradeRepository(connection).GetSortedGrades(result.Result.First().grade_id.ToString());
                var result3 = new SchoolRepository(connection).GetSortedSchools(result.Result.First().school_id.ToString());
                var result4 = new GenderRepository(connection).GetSortedGenders(result.Result.First().gender.ToString());
                var result5 = new HomeRoomRepository(connection).GetSortedHomeRooms(result.Result.First().homeroom_id.ToString());

                coll.singleStudent = (IEnumerable <Models.Student>)result1.Result.ToArray();
                coll.allGrades = (IEnumerable<Models.Grade>)result2.Result.ToArray();
                coll.allSchools = (IEnumerable<Models.School>)result3.Result.ToArray();
                coll.allGenders = (IEnumerable<Models.Gender>)result4.Result.ToArray();
                coll.allHomeRooms = (IEnumerable<Models.HomeRoom>)result5.Result.ToArray();

                coll.gradeselectlist = new SelectList(result2.Result.ToList(), "grade_id", "grade_value", new { id = "TxtGrade", @required = "required" });
                coll.schoolselectlist = new SelectList(result3.Result.ToList(), "school_id", "name", new { id = "TxtSchool", @required = "required" });
                coll.genderselectlist = new SelectList(result4.Result.ToList(), "gender", "gender", new { id = "TxtGender", @required = "required" });
                coll.homeroomselectlist = new SelectList(result5.Result.ToList(), "homeroom_id", "homeroom_name", new { id = "TxtHomeroom", @required = "required" });

            }
            return View(coll);
        }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:32,代码来源:EditStudentController.cs

示例2: GetRemedialAction

 public async System.Threading.Tasks.Task<ActionResult> GetRemedialAction(string id)
 {
     using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
     {
         await connection.OpenAsync();
         var result = await new RemedialActionRepository(connection).GetRemedialAction(id);
         return View(result);
     }
 }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:9,代码来源:RemedialActionController.cs

示例3: CodeOfConductViolation

 // GET: CodeOfConductViolation
 public async System.Threading.Tasks.Task<ActionResult> CodeOfConductViolation()
 {
     using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
     {
         await connection.OpenAsync();
         var result = await new CodeOfConductViolationRepository(connection).GetCodeOfConductViolations();
         return View(result);
     }
 }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:10,代码来源:CodeOfConductViolationController.cs

示例4: Profile

 // GET: Student
 public async System.Threading.Tasks.Task<ActionResult> Profile()
 {
     using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
     {
         await connection.OpenAsync();
         var result = await new ProfileRepository(connection).GetProfiles();
         //var result2 = await new SchoolRepository(connection).GetSchools();
         return View(result);
     }
 }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:11,代码来源:ProfileController.cs

示例5: Grade

 // GET: Student
 public async System.Threading.Tasks.Task<ActionResult> Grade()
 {
     Session["Grades"] = null;
     using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
     {
         await connection.OpenAsync();
         var result = await new GradeRepository(connection).GetGrades();
         Session["Grades"] = result;
         return View(result);
     }
 }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:12,代码来源:GradeController.cs

示例6: SchoolYear

        // GET: SchoolYear
        public async System.Threading.Tasks.Task<ActionResult> SchoolYear()
        {
            SchoolYearCollection coll = new SchoolYearCollection();

            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();
                var result = new SchoolYearRepository(connection).GetSchoolYears();
                coll.allSchoolYears = (IEnumerable<Models.SchoolYear>)result.Result.ToArray();
            }
            return View(coll);
        }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:13,代码来源:SchoolYearController.cs

示例7: TestConnectivityAsync

 public async Task<bool> TestConnectivityAsync(string connectionString)
 {
     try
     {
         using (var conn = new MySqlConnection(connectionString))
         {
             await conn.OpenAsync();
             return true;
         }
     }
     catch
     {
         return false;
     }
 }
开发者ID:zanadu777,项目名称:Schema,代码行数:15,代码来源:ConnectivityTester.cs

示例8: EditOfficeVisit

        public async System.Threading.Tasks.Task<ActionResult> EditOfficeVisit(string id)
        {

            OfficeVisitCollection coll = new OfficeVisitCollection();

            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();
               
                var result = new StudentRepository(connection).GetStudents();
                var result2 = new ContactRepository(connection).GetContacts();
                var result3 = new ContentCourseRepository(connection).GetContentCourses();
                var result4 = new CodeOfConductViolationRepository(connection).GetCodeOfConductViolations();
                var result5 = new HomeRoomRepository(connection).GetHomeRooms();
                var result6 = new RemedialActionRepository(connection).GetRemedialActions();
                var result7 = new OfficeVisitRepository(connection).GetOfficeVisitByID(Convert.ToInt32(id));

                coll.officeVisit = result7.Result;
                
                coll.allStudents = (IEnumerable<Models.Student>)result.Result.ToArray();
                coll.allReporters = coll.allHandledBys = (IEnumerable<Models.Contact>)result2.Result.ToArray();
                coll.allLocations = (IEnumerable<Models.ContentCourse>)result3.Result.ToArray();
                coll.allCodeViolations = (IEnumerable<Models.CodeOfConductViolation>)result4.Result.ToArray();
                coll.allHomeRooms = (IEnumerable<Models.HomeRoom>)result5.Result.ToArray();
                coll.allRemedials = (IEnumerable<Models.RemedialAction>)result6.Result.ToArray();

                coll.remedialAction = new OfficeVisitRepository(connection).GetOfficeVisitRemedyAction(coll.officeVisit.office_visit_id);
                coll.CodeViolation = new OfficeVisitRepository(connection).GetOfficeVisitCodeViolation(coll.officeVisit.office_visit_id);

                coll.office_visit_id = coll.officeVisit.office_visit_id;
                coll.arrival_dt = coll.officeVisit.arrival_dt;
                coll.office_visit_dt = coll.officeVisit.office_visit_dt;
                coll.nap = coll.officeVisit.nap;
                coll.comments = coll.officeVisit.comments;

                coll.StudentSelectList =  new SelectList(coll.allStudents, "student_id", "student_name", coll.officeVisit.student_id);
                coll.ReportersSelectList = new SelectList(coll.allReporters, "contact_id", "contact_name", coll.officeVisit.sent_by_contact_id);
                coll.HomeRoomSelectList = new SelectList(coll.allHomeRooms, "homeroom_id", "homeroom_name", coll.officeVisit.homeroom_id);
                coll.HandleBySelectList = new SelectList(coll.allHandledBys, "contact_id", "contact_name", coll.officeVisit.handled_by_contact_id);
                coll.LocationSelectList = new SelectList(coll.allLocations, "content_course_id", "name", coll.officeVisit.content_course_id);
                
                coll.RemedialSelectList = new SelectList(coll.allRemedials, "remedial_action_id", "name", coll.remedialAction);
                coll.ViolationSelectList = new SelectList(coll.allCodeViolations, "code_of_conduct_violation_id", "name", coll.CodeViolation);
                Session["OfficeVisitId"] = id;
            }

            return View(coll);
        }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:48,代码来源:EditOfficeVisitController.cs

示例9: AddContact

        public async System.Threading.Tasks.Task<ActionResult> AddContact()
        {

            ContactCollection coll = new ContactCollection();

            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();

                var result2 = new SchoolRepository(connection).GetSchools();
                coll.allSchools = (IEnumerable<Models.School>)result2.Result.ToArray();
                coll.schoolselectlist = new SelectList(result2.Result.ToList(), "school_id", "name", new { @required = "required" });
            }

            return View(coll);
        }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:16,代码来源:AddContactController.cs

示例10: AddProfile

        public async System.Threading.Tasks.Task<ActionResult> AddProfile()
        {

            ProfileCollection coll = new ProfileCollection();

            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();

                var result = new ContactRepository(connection).GetContacts();
                coll.allContacts = (IEnumerable<Models.Contact>)result.Result.ToArray();
                coll.profilecontactselectlist = new SelectList(result.Result.ToList(), "contact_id", "contact_name", new { @required = "required" });
            }

            return View(coll);
        }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:16,代码来源:AddProfileController.cs

示例11: GetAll

        public async Task<IEnumerable<UserDto>> GetAll()
        {
            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();

                // Read all the userId's and userName's from the database, but don't send their password hashes.
                var result = await connection.QueryAsync<UserDto>(@"
SELECT 
UserId,
UserName
FROM 
User
");
                return result;
            }
        }
开发者ID:heptadassembly,项目名称:DemoApp,代码行数:17,代码来源:UserController.cs

示例12: EditRemedialAction

        public async System.Threading.Tasks.Task<ActionResult> EditRemedialAction(string id)
        {

            RemedialActionCollection coll = new RemedialActionCollection();

            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();
                var result = new RemedialActionRepository(connection).GetRemedialAction(id);
                var result2 = new RemedialActionRepository(connection).GetRemedialActions();

                coll.singleRemedialAction = (IEnumerable<Models.RemedialAction>)result.Result.ToArray();
                coll.allRemedialActions = (IEnumerable<Models.RemedialAction>)result2.Result.ToArray();
                coll.remedialactionselectlist = new SelectList(result2.Result.ToList(), "remedial_action_id", "name", new { id = "RemedialActionID", @required = "required" });
            }

            return View(coll);
        }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:18,代码来源:EditRemedialActionController.cs

示例13: OfficeVisit

        // GET: OfficeVisit
        public async System.Threading.Tasks.Task<ActionResult> OfficeVisit()
        {
            ViewBag.SuccessAdd = (Session["SuccessAdd"] == null)?false:true;

            if (ViewBag.SuccessAdd)
            {
                ModelState.AddModelError(string.Empty, "Office Visit has been successully been updated.");
                Session["SuccessAdd"] = null;
            }
            Session["OfficeVisits"] = null;
            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();
                var result = await new OfficeVisitRepository(connection).GetALLOfficeVisits();
                Session["OfficeVisits"] = result;
                return View(result);
            }
        }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:19,代码来源:OfficeVisitController.cs

示例14: EditProfile

        // GET: AddOfficeVisit
        public async System.Threading.Tasks.Task<ActionResult> EditProfile(int id)
        {

            ProfileCollection coll = new ProfileCollection();

            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();
                var result = new ProfileRepository(connection).GetProfile(id);
                var result2 = new ProfileRepository(connection).GetProfiles();
                var result3 = new ContactRepository(connection).GetSortedContacts(result.Result.First().contact_id.ToString());

                coll.singleProfile = (IEnumerable<Models.ProfileModel>)result.Result.ToArray();
                coll.allProfiles = (IEnumerable<Models.ProfileModel>)result2.Result.ToArray();
                coll.profilecontactselectlist = new SelectList(result3.Result.ToList(), "contact_id", "contact_name", new { id = "TxtContact", @required = "required" });
            }

            return View(coll);
        }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:20,代码来源:EditProfileController.cs

示例15: EditContact

        // GET: AddOfficeVisit
        public async System.Threading.Tasks.Task<ActionResult> EditContact(int id)
        {

            ContactCollection coll = new ContactCollection();

            using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString))
            {
                await connection.OpenAsync();
                var result = new ContactRepository(connection).GetContact(id);
                var result2 = new ContactRepository(connection).GetContacts();
                var result3 = new SchoolRepository(connection).GetSortedSchools(result.Result.First().school_id.ToString());

                coll.singleContact = (IEnumerable<Models.Contact>)result.Result.ToArray();
                coll.allContacts = (IEnumerable<Models.Contact>)result2.Result.ToArray();
                coll.schoolselectlist = new SelectList(result3.Result.ToList(), "school_id", "name", new { id = "TxtSchool", @required = "required" });
            }

            return View(coll);
        }
开发者ID:heptadassembly,项目名称:SAMsUNFWebApplication,代码行数:20,代码来源:EditContactController.cs


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