DataContext Exceptions in v5.70

DataContext Exceptions in v5.70

Postby kautuk » Mon 26 Apr 2010 11:29

we were using your product dotConnect for MySQL ver5.20 since last year
and our LINQ code was working perfectly.

But now we have shifted to newer version of the same ie.5.70
After reapplying the references to our project (.NET 3.5 console app)
we are facing some strange errors like

.First() method is throwing exception: "sequence contains no elements."
.Refresh() method is throwing an exception: "value cannot be null: param entities".

our code lines are as follows:

System.ArgumentNullException was caught
Message="Value cannot be null.\r\nParameter name: entities"
at Devart.Data.Linq.DataContext.Refresh(RefreshMode mode, Object[] entities)
at CLEO.BO.Document.SaveDocument(String strStatus) in D:\CLEO\trunk\service\CLEO\CLEO\Document.cs:line 390
at CLEO.BO.Document.Draft() in D:\CLEO\trunk\service\CLEO\CLEO\Document.cs:line 326
at CLEO.BO.DocumentManager.Create(IWorkflowable doc, String strWorkflow, Boolean blnDraft) in D:\CLEO\trunk\service\CLEO\CLEO\DocumentManager.cs:line 137

Categories objCategory = dbcon.Categories.Where(a => a.Category == strParentCat).FirstOrDefault();

both the codelines were working before, but not now.
second exception was solved by using .FirstOrDefault() method.

but why these errors are occurring now and not before.????
please note that all the references are given properly to newer assemblies after the v5.70 installation.. we are able to build our project successfully. It means these are runtime errors.

Please help us out.
Posts: 4
Joined: Mon 26 Apr 2010 11:02

Postby AndreyR » Wed 28 Apr 2010 13:49

Both exceptions were added for Microsoft LINQ to SQL compatibility reasons.
First() should throw exception in case when the collection is empty.
When Refresh() is called the entity set should be passed as a parameter, in other case the exception should be raised.
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Return to dotConnect for MySQL