【发布时间】:2013-02-13 14:23:30
【问题描述】:
在使用 C# 中的 LINQ 将数据插入 SQL Server 08R2 中的表时,我似乎遇到了这个问题。无论我尝试过什么,INSERTONSUBMIT() 都会出现错误。
这是代码...
private void testUpdateUNITBC()
{
using (unitDataContext unit = new unitDataContext())
{
unitnotest unitbc = new unitnotest();
unit.FBARCO = "1234";
unit.FUNITNO = "1234";
unit.FJOBNO = "I9999-0000";
unit.FBOXNO = "999";
unit.FOPNO = "999";
unit.UNITBCs.InsertOnSubmit(unitbc); <--this is where I get the error
};
错误读取
void Table.InsertOnSubmit(UNITBC 实体) 将处于挂起插入状态的实体添加到此 System.Data.Linq.Table。 错误: 'System.Data.Linq.Table.InsertOnSubmit(AS5553.UNITBC)' 的最佳重载方法匹配有一些无效参数
我用来保存变量的容器与表数据类型匹配。 (string 到 varchar(64))
我知道我接下来需要unit.SubmitChanges();,但这没关系,因为我无法通过INSERTONSUBMIT() 点。任何帮助都会很棒,因为我已经尝试了几件事并花了一整天的时间进行研究。
更新
这是所要求的 unitnote 类...
public class unitnotest
{
public string FBARCO {get;set;}
public string FUNITNO {get;set;}
public string FJOBNO {get;set;}
public string FBOXNO {get;set;}
public string FOPNO {get;set;}
}
【问题讨论】:
-
你能发布 unitnote 的构造吗?
-
错误提示
InsertOnSubmit(UNITBC entity)is Expecting UNITBC type and you are passingunitnotest
标签: c# linq linq-to-sql invalid-argument insertonsubmit