不确定这会有帮助,但它
看起来像
你所拥有的应该有用。我倾向于使用SQL Server,但ADO。网络层为
主要地
同样,我尝试了以下案例:
using Dapper;
using System.Data.SqlClient;
using System.Linq;
public class Students
{
private string name;
private string age;
private string adress;
public Students(string name, string age, string adress)
{
this.name = name;
this.age = age;
this.adress = adress;
}
public override string ToString() => $"{name}, {age}, {adress}";
}
static class P
{
static void Main()
{
using (var connection = new SqlConnection("Data Source=.;Initial Catalog=master;Integrated Security=SSPI;"))
{
const string myQuery = "select 'fred' as [name], '27' as [age], 'somewhere' as [adress]";
var studentsInfo = connection.Query<Students>(myQuery).ToList();
foreach(var student in studentsInfo)
{
System.Console.WriteLine(student);
}
}
}
}
它运行良好,输出:
fred, 27, somewhere
所以我的主要想法是:查询是否输出您认为它输出的内容?数据是你认为的吗?还有:你确定吗
age
是一个
string
?