本文介绍了sql:'MYDataContext'不包含'InsertOnSubmit'的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to add a row to a table:

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();
    }

但我收到此错误:

我该如何解决?

推荐答案

datacontext本身没有InsertOnSubmit.您需要添加实体.像这样:

There is no InsertOnSubmit on the datacontext itsself.You need to add the entity. Something like:

这篇关于sql:'MYDataContext'不包含'InsertOnSubmit'的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 17:17