为什么会出现这个异常?虽然代码不完全相同,但很接近“演示”https://gist.github.com/1599013
异常信息:MissingMethodException
描述:
方法未找到:'System.Collections.Generic.IEnumerable
代码
描述:
方法未找到:'System.Collections.Generic.IEnumerable
1<System.Object> Dapper.SqlMapper.Query(System.Data.IDbConnection, System.String, System.Object, System.Data.IDbTransaction, Boolean, System.Nullable
1, System.Nullable`1)'。代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using Dapper;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
namespace daconsole2
{
class Program
{
class Product
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTime? LastPurchase { get; set; }
}
// container with all the tables
class MyDatabase : Database<MyDatabase>
{
public Table<Product> Products { get; set; }
}
//*/
static void Main(string[] args)
{
var cnn = new MySqlConnection("uid=name;pwd=pw;Port=3306;database=test");
cnn.Open();
var db = MyDatabase.Init(cnn, commandTimeout: 2);
//if(false)
db.Execute(@"create table Products (
Id int primary key,
Name varchar(20),
Description TEXT,
LastPurchase datetime)");
var productId = db.Products.Insert(new { Name = "Hello", Description = "Nothing" });
//var db = cnn;
Console.ReadKey();
}
}
}