I am having problems returning a single object from a Dapper query. I have a simple query and I want to get the first object from the returned collection. What am I missing?
using (SqlConnection sqlConnection = new SqlConnection(GetConnectionString()))
{
string query = @"select * from order";
sqlConnection.Open();
// Works
var orders = sqlConnection.Query<OrderModel>(query);
// Does Not Work ERROR: "does not contain a definition for 'FirstOrDefault' and
// no extension method 'FirstOrDefault'
// accepting a first argument of type 'System.Collections.Generic.IEnumerable<OrderModel>'"
var order = sqlConnection.Query<OrderModel>(query).FirstOrDefault();
}
select top 1 * ...
? – leppie Sep 6 '14 at 22:08using System.Linq;
at the top – Marc Gravell♦ Sep 6 '14 at 22:57