I seem to be running into this issue with inserting data into a table in a SQL Server 08R2 using LINQ in C#. No matter what I've tried I keep getting an error with INSERTONSUBMIT()
.
Here is the code...
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
};
The error reads
void Table.InsertOnSubmit(UNITBC entity) Adds an entity in a pending insert state to this System.Data.Linq.Table. Error: The best overloaded method match for 'System.Data.Linq.Table.InsertOnSubmit(AS5553.UNITBC)' has some invalid arguments
The container I used to hold the variables matches the table datatypes. (string
to varchar(64)
)
I know I need the unit.SubmitChanges();
next but it doesn't matter as I can't get passed the INSERTONSUBMIT()
point. Any help would be great as I've tried several things and spent the entire day working on this with research.
Update
Here is the unitnotest class as requested...
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;}
}