1

我是 Micro-ORM 的新手,我正在使用 dapper fluent mapping 和 dommel 我尝试插入/添加条目,但遇到此错误“找不到类型的关键属性”这是我的代码

        using (IDbConnection con = new MySqlConnection(cnxStr))
        {
            con.Open();
            equipment eqp = new equipment 
            {
                category_id     = 1, 
                barcode         = "DDH-003",
                asset_number    = "45645645", 
                equipment_name  = "DBD Dew", 
                equipment_description = "Thin Can", 
                manufacturer_id = 3, 
                model           = "Blah", 
                serialnumber    = "11111", 
                status          = "Good", 
                service_group   = "SGE", 
                required_pm     = "Yes", 
                service_provider="111", 
                frequency       = 1, 
                department_id   = 1, 
                location_id     = 1, 
                availability    = "Avail", 
                register_id     = 1, 
                supplier_id     = 1, 
                conditionstatus_id = 1, 
                status_id       = 1, 
                utilization_id = 3
            };
            int count = con.Insert<equipment>(eqp); <-- error here
            if (count > 0) 
            {
                MessageBox.Show("Successfully Added", "Successfully Added -:", MessageBoxButtons.OK, MessageBoxIcon.Information); 
            }
            con.Close();

        }
4

1 回答 1

0

Dapper 假定您的数据库模型中有一个名为 Id 的列,除非您另有指定。另一方面,在这种情况下,您使用的是来自 Dapper.Contrib 的扩展。为此,您必须在[key]主键上方添加一个指令。

于 2016-04-21T10:54:48.777 回答