3

My boss is a very smart man, but sometimes he's superstitious as hell. He cannot trust context.list.find() in c# to accept null values, despite that being a thing forever. He's certain that it will break in a future entity framework update, so we have all these duplicate if statements all over our site.

If(blah == null){ //stuff}
Thing thing = context.things.find(blah);
If(thing == null){//stuff}

It kills me a little each time, but I guess he could be worse. I'm glad that he's finally trusting the null conditional operator, because it's a fucking lifesaver for duplicate code!

Comments
  • 3
    Sounds like someone who has been burned once to often by api changes and no longer trusts them .... and to be honest with EF I can sympathise
  • 0
    Welp, apparently it still executes a SQL query to find null, so the if stays. Dammit, but he's right.
  • 0
    @iam13islucky wouldn't it be easier to execute a stored procedure or select from a view than have static/dynamic SQL! At least the selection logic would be separate from the orm entity code !
Add Comment