locked
Map MySqlCommand to C# class RRS feed

  • Question

  • User1315867932 posted

    Using a MySqlConnection instance I want to be able to store the result of a MySqlCommand as a defined C# Class or a List<T>.
    For instance I have a data model class User.cs and I want to map the result of the MySqlCommand to an instance of this class.

    Something like this:

    var sql = @"SELECT * FROM User WHERE UserID = @userId;";
    using (var conn = new MySqlConnection(connStr))
    {
        User user = new MySqlCommand(sql, conn);
    }

    Monday, September 11, 2017 6:09 AM

All replies