Click here to Skip to main content
12,621,492 members (35,602 online)

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
NewsExtract from the code I'm working on Pin
Super Lloyd10-Dec-12 17:26
memberSuper Lloyd10-Dec-12 17:26 
GeneralRe: Extract from the code I'm working on Pin
Zac Greve10-Dec-12 18:57
memberZac Greve10-Dec-12 18:57 
GeneralRe: Extract from the code I'm working on Pin
Super Lloyd10-Dec-12 19:13
memberSuper Lloyd10-Dec-12 19:13 
GeneralRe: Extract from the code I'm working on Pin
KP Lee11-Dec-12 13:08
memberKP Lee11-Dec-12 13:08 
GeneralRe: Extract from the code I'm working on Pin
Super Lloyd11-Dec-12 23:04
memberSuper Lloyd11-Dec-12 23:04 
GeneralRe: Extract from the code I'm working on Pin
Nemanja Trifunovic13-Dec-12 8:29
memberNemanja Trifunovic13-Dec-12 8:29 
GeneralRe: Extract from the code I'm working on Pin
Super Lloyd13-Dec-12 14:12
memberSuper Lloyd13-Dec-12 14:12 
GeneralNo foreign keys on the first date. Pin
Brady Kelly9-Dec-12 3:21
memberBrady Kelly9-Dec-12 3:21 
I wrote this little workaround earlier this year. EF complains about an insert where ParentId is set, but allows me to set it with an update.
// TODO Address this cluster-wtf.
using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
{
    if (newProject.ParentId != null)
    {
        // I don't know why I need this, but EF won't insert with a ParentId, but allows me to set it immediately after.
        int parentId = newProject.ParentId.Value;
        newProject.ParentId = null;
        _projectRepository.Insert(newProject);
        newProject.ParentId = parentId;
        _projectRepository.Update(newProject);
    }
    else
    {
        _projectRepository.Insert(newProject);
    }
    scope.Complete();
}

GeneralRe: No foreign keys on the first date. Pin
KP Lee11-Dec-12 9:17
memberKP Lee11-Dec-12 9:17 
GeneralRe: No foreign keys on the first date. Pin
Brady Kelly11-Dec-12 9:34
memberBrady Kelly11-Dec-12 9:34 
GeneralRe: No foreign keys on the first date. Pin
KP Lee11-Dec-12 12:33
memberKP Lee11-Dec-12 12:33 
GeneralRe: No foreign keys on the first date. Pin
Pete O'Hanlon11-Dec-12 10:10
protectorPete O'Hanlon11-Dec-12 10:10 
GeneralRe: No foreign keys on the first date. Pin
Brady Kelly11-Dec-12 17:36
memberBrady Kelly11-Dec-12 17:36 
GeneralRe: No foreign keys on the first date. Pin
Andrew Rissing13-Dec-12 7:42
memberAndrew Rissing13-Dec-12 7:42 
GeneralRe: No foreign keys on the first date. Pin
ryan_b200917-Dec-12 7:55
memberryan_b200917-Dec-12 7:55 
GeneralRe: No foreign keys on the first date. Pin
Brady Kelly17-Dec-12 8:04
memberBrady Kelly17-Dec-12 8:04 
GeneralHow do you like your nulls Pin
Robert Hoffmann8-Dec-12 2:57
memberRobert Hoffmann8-Dec-12 2:57 
GeneralRe: How do you like your nulls Pin
Zac Greve8-Dec-12 8:25
memberZac Greve8-Dec-12 8:25 
GeneralRe: How do you like your nulls Pin
lewax008-Dec-12 16:32
memberlewax008-Dec-12 16:32 
GeneralRe: How do you like your nulls Pin
Zac Greve8-Dec-12 17:23
memberZac Greve8-Dec-12 17:23 
GeneralRe: How do you like your nulls Pin
lewax008-Dec-12 17:33
memberlewax008-Dec-12 17:33 
AnswerRe: How do you like your nulls Pin
Robert Hoffmann9-Dec-12 0:55
memberRobert Hoffmann9-Dec-12 0:55 
GeneralRe: How do you like your nulls Pin
lewax009-Dec-12 1:35
memberlewax009-Dec-12 1:35 
GeneralRe: How do you like your nulls Pin
Robert Hoffmann9-Dec-12 10:39
memberRobert Hoffmann9-Dec-12 10:39 
GeneralRe: How do you like your nulls Pin
patbob10-Dec-12 6:32
memberpatbob10-Dec-12 6:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.161128.1 | Last Updated 3 Dec 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid