1

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Wally_the_Walrus
  • 219
  • 1
  • 5
  • 17

1 Answers1

2

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>();
    }
}
Memoizer
  • 2,231
  • 1
  • 14
  • 14