有什么方法可以从 bltoolkit 获取 SQL 查询结果?我需要明确设置查询..
例如:
SELECT * FROM table
谢谢
是的。DbManager 类包含一些适当的方法:ExecuteList、ExecuteReader、ExecuteObject、ExecuteDataTable、SetSpCommand 等。参见:http ://bltoolkit.net/Doc.Data.ashx
样本:
[MapField("PersonID", "ID")]
public class Person
{
public int ID;
public string LastName;
public string FirstName;
public string MiddleName;
public Gender Gender;
}
IList<Person> GetPersonListSqlText()
{
using (DbManager db = new DbManager())
{
return db
.SetCommand("SELECT * FROM Person")
.ExecuteList<Person>();
}
}