简体   繁体   English

Visual Studio QueryFirst 扩展

[英]Visual Studio QueryFirst Extension

To those, who use QueryFirst ( https://www.codeproject.com/tips/1108776/queryfirst-world-first-implementation-of-the-domin )对于那些使用 QueryFirst ( https://www.codeproject.com/tips/1108776/queryfirst-world-first-implementation-of-the-domin )

How to connect it to a Wampserver MySQL database?如何将其连接到 Wampserver MySQL 数据库? I have connected the db to my project with我已将数据库连接到我的项目

Connect to Database连接到数据库

in

Server Explorer服务器浏览器

But with the Connect icon of QueryFirst I cannot attach my db to Query1.sql.但是使用 QueryFirst 的连接图标,我无法将我的数据库附加到 Query1.sql。

  1. You will need to create a connection string called QfDefaultConnection in your app or web.config.您需要在您的应用程序或 web.config 中创建一个名为 QfDefaultConnection 的连接字符串。
  2. specify the ADO provider MySql (providerName="MySql.Data.MySqlClient") are supported.指定支持 ADO 提供程序 MySql (providerName="MySql.Data.MySqlClient")。 This data source will be used at design time to retrieve the schema.此数据源将在设计时用于检索架构。 At runtime.在运行时。
  3. you need to supply a class, QfRuntimeConnection, with a static method GetConnection().您需要为类 QfRuntimeConnection 提供静态方法 GetConnection()。 You must supply this class, but you can always manage the connection yourself if you have other ideas.你必须提供这个类,但如果你有其他想法,你总是可以自己管理连接。 The compiler will show you the way !编译器会告诉你方法!

Here is a sample for your reference.这是一个示例供您参考。

https://1drv.ms/u/s!AlvaNEnglADDgQU4I1v9w2nMEIS2 https://1drv.ms/u/s!AlvaNEnglADDgQU4I1v9w2nMEIS2

In your app.config, you'll need a connection string like this...在你的 app.config 中,你需要一个像这样的连接字符串......

<add name="QfDefaultConnection" connectionString="Server=localhost;Database=dbname;Uid=root;Pwd=Dimosoftware=1;AllowUserVariables=True;" providerName="MySql.Data.MySqlClient"></add>

and code...和代码...

using System;
using System.Configuration;
using System.Data;
using MySql.Data.MySqlClient;

namespace YourApp
{
    class QfRuntimeConnection
    {
        public static IDbConnection GetConnection()
        {
            return new MySqlConnection(ConfigurationManager.ConnectionStrings["QfDefaultConnection"].ConnectionString);
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM