Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Lost in composition

Lost in composition

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharplinq
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Duncan Edwards Jones
    wrote on last edited by
    #1

    Sometimes people get a little bit LINQ giddy:-

    int fileFormtId = ds.Tables["ExpectedDailyBrokerFiles"].AsEnumerable().Where(x => Fits(Utils.ISS(row["File Name"]), x.Field("Mask")) && x.Field("CHID").HasValue && x.Field("CHID").Value == Utils.ISInt(row["FileSourceID"])).Select(x => x.Field("FileFormatId")).ToList().FirstOrDefault();

    M 1 Reply Last reply
    0
    • D Duncan Edwards Jones

      Sometimes people get a little bit LINQ giddy:-

      int fileFormtId = ds.Tables["ExpectedDailyBrokerFiles"].AsEnumerable().Where(x => Fits(Utils.ISS(row["File Name"]), x.Field("Mask")) && x.Field("CHID").HasValue && x.Field("CHID").Value == Utils.ISInt(row["FileSourceID"])).Select(x => x.Field("FileFormatId")).ToList().FirstOrDefault();

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #2

      Well, if you remove all the other cruft, a AsEnumerable().Where().Select().FirstOrDefault() isn't that bad. However, ToList().FirstOrDefault() is overkill, and with nullable types, why check for HasValue? Marc

      Latest Article - Merkle Trees Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

      D 1 Reply Last reply
      0
      • M Marc Clifton

        Well, if you remove all the other cruft, a AsEnumerable().Where().Select().FirstOrDefault() isn't that bad. However, ToList().FirstOrDefault() is overkill, and with nullable types, why check for HasValue? Marc

        Latest Article - Merkle Trees Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

        D Offline
        D Offline
        Duncan Edwards Jones
        wrote on last edited by
        #3

        ..and the mixing type safe and type unsafe field access ..and the fact that it's wrong but I can't see where ..and its a client side join between tables for which a server side view already exists and so on. :-)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups