public static void AddFile(string filename, int folderId) { using (var dc = new TestDataContext()) { var folder = new Folder { FolderId = folderId }; dc.Attach(folder, false); AddFile(dc, filename, folder); dc.SubmitChanges(); } }