如何在Visual Studio Code中配置一个带有连接字符串的C#程序?
这是针对使用.Net Core SDK版本2.2.203的.Net Core 2.2,在Visual Studio Code 1.34.0中进行的。
我尝试将App.Config文件添加到项目中,但我无法解决这个问题。请告诉我任何配置连接字符串的解决方案。
这是针对使用.Net Core SDK版本2.2.203的.Net Core 2.2,在Visual Studio Code 1.34.0中进行的。
我尝试将App.Config文件添加到项目中,但我无法解决这个问题。请告诉我任何配置连接字符串的解决方案。
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Collections.Specialized;
using Dapper;
namespace Sample_Dapper
{
class Program
{
static void Main(string[] args)
{
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
var SqlString = "SELECT TOP 100 [CustomerID],[CustomerFirstName],
[CustomerLastName],[IsActive] FROM [Customer]";
var ourCustomers = (List<Customer>)db.Query<Customer>(SqlString);
}
}
}