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. General Programming
  3. LINQ
  4. Getting List of Names which starts with numeric

Getting List of Names which starts with numeric

Scheduled Pinned Locked Moved LINQ
tutorial
2 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.
  • N Offline
    N Offline
    Nath
    wrote on last edited by
    #1

    Hi, I have a column in table 'str_Name'of type string. It contains the data as shown below. Vishnu Rajesh 12Sharma 02Santhosh 34657Chandu Anita Swapna 987fhug Deepika Divya Janaki My requirement is to get names which starats with numerics Please suggest me how to achieve this. Thanks in Advance

    H 1 Reply Last reply
    0
    • N Nath

      Hi, I have a column in table 'str_Name'of type string. It contains the data as shown below. Vishnu Rajesh 12Sharma 02Santhosh 34657Chandu Anita Swapna 987fhug Deepika Divya Janaki My requirement is to get names which starats with numerics Please suggest me how to achieve this. Thanks in Advance

      H Offline
      H Offline
      Howard Richards
      wrote on last edited by
      #2

      See my blog post[^] You need to map a .NET function to SQL to do this. The starting point is what string methods[^] are supported as translatins to SQL in LINQ? There isn't a way to map a function such as char.IsNumeric I think, so I found this solution (using VB.NET)

      'Create a char array using digits
      dim digits as char() = "0123456789"
      dim query = from x in myTable _
      where digits.Contains(x.str_Name.Substring(0,1)) _
      select x

      Tested on LINQpad and it works! You might need a not null clause if any str_name is null or blank.

      'Howard

      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