title: Error deleting a record using Linq2SQL
body: <p>I've received an error report from a client recently and am having no luck resolving it. I'm hoping someone can give me some insight to what may be wrong. </p>
  
  <p>The error seems simple enough: </p>
  
  <p>Csla.DataPortalException: DataPortal.Delete failed (System.InvalidOperationException: Sequence contains more than one element at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)</p>
  
  <p>Here is my DataPortal_Delete method, which takes the FileId (PK) as a parameter.</p>
  
  <pre><code>private void DataPortal_Delete(SingleCriteria&lt;File, Guid&gt; criteria)
      {
          using (var ctx = ContextManager&lt;Ronin.Data.RoninDataContext&gt;
                      .GetManager(Database.ApplicationConnection, false))
          {
              var data = ctx.DataContext.Files
                      .Single(row =&gt; row.FileId == criteria.Value);
  
              ctx.DataContext.FileSources.DeleteAllOnSubmit(data.FileSources);
  
              ctx.DataContext.Files.DeleteOnSubmit(data);
  
              ctx.DataContext.SubmitChanges();
          }
      }
  </code></pre>
  
  <p>First thing I check was to see if there was another record with the same FileId (although being the primary key, this should be impossible). All FileIds were in fact unique. I launched the application connecting to the client database and tried to delete the record and it worked without any issues. The IT guy at the client site used the "Problem Step Recorder" to send me step by step screenshots of the actions taken by the user. Nothing out of the ordinary, and when he used a different machine, he was able to delete the record without any errors. Apparently this only happens when the application is run in Windows 7.</p>
  
  <p>That said, any ideas as to what could be causing this? </p>