private void button1_Click(object sender, EventArgs e)
{
DataClasses1DataContext dc = new DataClasses1DataContext();
var rec = dc.reportsSents.FirstOrDefault();
int rowCount = dc.reportsSents.Count();
if (rec != null)
{
for(int i = 0; i <= rowCount;)
{
var matchedCaseNumber = (from CaseNumberKey in dc.GetTable<reportsSent>()
select CaseNumberKey).FirstOrDefault();
(new MyReportRenderer()).RenderTest(Convert.ToString(matchedCaseNumber));
dc.reportsSents.DeleteOnSubmit(matchedCaseNumber);
dc.SubmitChanges();
i = (i +1);
}
}
When the code above is executed I get this error:
Value cannot be null. Parameter name:
entity
and matchedCaseNumber is highlighted in this line:
dc.reportsSents.DeleteOnSubmit(matchedCaseNumber);
What does this mean and why am I getting it. What I am trying to do is pass MatchedCaseNumber to the method and then delete it after the method is executed and then step through the table. Any help would be appreciated.
Thanks.
matchedCaseNumberis probablynullwhen passed toDeleteOnSubmitEDIT:
If I understand correctly what you’re trying to do, this would be better: