I recently received an error message from a client and I was not able to resolve it. I hope someone can give me some idea of ββwhat might be wrong.
The error seems simple enough:
Csla.DataPortalException: DataPortal.Delete failed (System.InvalidOperationException: The sequence contains more than one element in System.Linq.Enumerable.SingleOrDefault [TSource] (source IEnumerable`1)
Here is my DataPortal_Delete method, which takes a FileId (PK) parameter as a parameter.
private void DataPortal_Delete(SingleCriteria<File, Guid> criteria) { using (var ctx = ContextManager<Ronin.Data.RoninDataContext> .GetManager(Database.ApplicationConnection, false)) { var data = ctx.DataContext.Files .Single(row => row.FileId == criteria.Value); ctx.DataContext.FileSources.DeleteAllOnSubmit(data.FileSources); ctx.DataContext.Files.DeleteOnSubmit(data); ctx.DataContext.SubmitChanges(); } }
The first thing I checked was to check if there was another entry with the same FileId (although it was a primary key, this should be impossible). All FileIds were truly unique. I launched the application connecting to the client database and tried to delete the entry and it worked without any problems. An IT guy on a client site used the Problem Step Recorder to send me step-by-step screenshots of the actions taken by the user. Nothing unusual, and when he used another machine, he was able to delete the record without any errors. Apparently, this only happens when the application starts in Windows 7.
However, any ideas as to what might be causing this?
linq-to-sql csla
Buddy lee
source share