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. SQL to LINQ

SQL to LINQ

Scheduled Pinned Locked Moved LINQ
databasecsharplinqquestion
4 Posts 3 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
    Nilish
    wrote on last edited by
    #1

    Hi, how should I write the following query in LINQ ?

    @TableName nvarchar(128)

    DECLARE @DB_NAME NVARCHAR(128)
    SET @DB_NAME = DB_NAME()

    SELECT COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_CATALOG = @DB_NAME
    AND TABLE_SCHEMA = 'dbo'
    AND TABLE_NAME = @TableName
    ORDER BY ORDINAL_POSITION

    Regards

    H J 2 Replies Last reply
    0
    • N Nilish

      Hi, how should I write the following query in LINQ ?

      @TableName nvarchar(128)

      DECLARE @DB_NAME NVARCHAR(128)
      SET @DB_NAME = DB_NAME()

      SELECT COLUMN_NAME
      FROM INFORMATION_SCHEMA.COLUMNS
      WHERE TABLE_CATALOG = @DB_NAME
      AND TABLE_SCHEMA = 'dbo'
      AND TABLE_NAME = @TableName
      ORDER BY ORDINAL_POSITION

      Regards

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

      You shouldn't. The information schema tables are not visible in LINQ (they are virtual views created by the server). If you really need to do this through LINQ then use .ExecuteQuery

      'Howard

      N 1 Reply Last reply
      0
      • H Howard Richards

        You shouldn't. The information schema tables are not visible in LINQ (they are virtual views created by the server). If you really need to do this through LINQ then use .ExecuteQuery

        'Howard

        N Offline
        N Offline
        Nilish
        wrote on last edited by
        #3

        Hi Howards, How r u? can u provide a link or any chunk of code? Thanks

        1 Reply Last reply
        0
        • N Nilish

          Hi, how should I write the following query in LINQ ?

          @TableName nvarchar(128)

          DECLARE @DB_NAME NVARCHAR(128)
          SET @DB_NAME = DB_NAME()

          SELECT COLUMN_NAME
          FROM INFORMATION_SCHEMA.COLUMNS
          WHERE TABLE_CATALOG = @DB_NAME
          AND TABLE_SCHEMA = 'dbo'
          AND TABLE_NAME = @TableName
          ORDER BY ORDINAL_POSITION

          Regards

          J Offline
          J Offline
          John Ad
          wrote on last edited by
          #4

          Hi Nilish, Try these links: Link #1[^] Link #2[^] Link #3[^] I hope these would be helpful.

          John Adams ComponentOne LLC. www.componentone.com

          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