当前位置: 首页 > 工具软件 > BLToolkit > 使用案例 >

BLToolkit sql query set explicitly

楚煜
2023-12-01

Question

Is there any way how to get a SQL query result from a bltoolkit? I need to set the query explicitly..

for example:

SELECT * FROM table

thanks

Best Answer

Yes. The DbManager class contains some appropriate methods: ExecuteList, ExecuteReader, ExecuteObject, ExecuteDataTable, SetSpCommand, etc. See there:http://bltoolkit.net/Doc.Data.ashx

Sample:

[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>();
    }
}
 类似资料:

相关阅读

相关文章

相关问答