0

我正在尝试向表中添加一行:

MYDataContext dc = new MYDataContext("MYConnectionString");

    using (MYDataContext db = new MYDataContext("MYConnectionString"))
    {
        NotificationLog n = new NotificationLog();
        n.result = result;
        n.context = message;
        n.tomobiles = phoneprefix + phone;
        n.datesent = DateTime.Now;
        n.SMSprovider = provider; 
        db.InsertOnSubmit(n);
        db.SubmitChanges();
    }

但我得到这个错误:

“MYDataContext”不包含“InsertOnSubmit”的定义,并且找不到接受“MYDataContext”类型的第一个参数的扩展方法“InsertOnSubmit”(您是否缺少 using 指令或程序集引用?)

我该如何解决?

4

1 回答 1

0

数据上下文本身没有 InsertOnSubmit。您需要添加实体。就像是:

db.NotificationLog s .InsertOnsubmit(n)

于 2018-04-23T17:55:06.233 回答