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. LINQ to Entities - how to persist column order?

LINQ to Entities - how to persist column order?

Scheduled Pinned Locked Moved LINQ
tutorialcsharplinqhelpquestion
3 Posts 2 Posters 2 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
    Dmitry Otblesk
    wrote on last edited by
    #1

    Within LINQ to Entities entity model (supported by .edmx file) sometimes column order changes within the tables. It may happen after you’ve edited the table structure (added or deleted columns, renamed them, etc.). As a result an automatically generated Create method changes and existing code becomes broken. Example: You have entity called Item. It has columns ColA, ColB, ColC. Entity model designer generated method Item.CreateItem(ColA, ColB, ColC) for you. After some changes (which by the way have nothing to do with ColA, ColB, ColC !) the CreateItem method is now Item.CreateItem(ColB, ColA, ColC) As a result all your existing code, which calls CreateItem method, fails. Very annoying. Did anybody find the way how to persist the column order? Or at least how to control it? I tried to edit .edmx file directly and set up an order I need. But even this did not help. The Entity model designer is not following this order and it looks like it is picking up the order randomly.

    N 1 Reply Last reply
    0
    • D Dmitry Otblesk

      Within LINQ to Entities entity model (supported by .edmx file) sometimes column order changes within the tables. It may happen after you’ve edited the table structure (added or deleted columns, renamed them, etc.). As a result an automatically generated Create method changes and existing code becomes broken. Example: You have entity called Item. It has columns ColA, ColB, ColC. Entity model designer generated method Item.CreateItem(ColA, ColB, ColC) for you. After some changes (which by the way have nothing to do with ColA, ColB, ColC !) the CreateItem method is now Item.CreateItem(ColB, ColA, ColC) As a result all your existing code, which calls CreateItem method, fails. Very annoying. Did anybody find the way how to persist the column order? Or at least how to control it? I tried to edit .edmx file directly and set up an order I need. But even this did not help. The Entity model designer is not following this order and it looks like it is picking up the order randomly.

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      I haven't experienced this and can't seem to reproduce it


      I know the language. I've read a book. - _Madmatt

      D 1 Reply Last reply
      0
      • N Not Active

        I haven't experienced this and can't seem to reproduce it


        I know the language. I've read a book. - _Madmatt

        D Offline
        D Offline
        Dmitry Otblesk
        wrote on last edited by
        #3

        Well, it is obviously difficult to reproduce as effect is random. Sometimes it happens sometimes it does not.

        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