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. Database & SysAdmin
  3. Database
  4. LINQTOSQL at runtime

LINQTOSQL at runtime

Scheduled Pinned Locked Moved Database
csharpquestionhelpdatabasesql-server
4 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.
  • W Offline
    W Offline
    wjbjnr
    wrote on last edited by
    #1

    Hi ! I have a very odd problem. I am using LinqtoSql in my project in c#. , and what i do is i create a new table and set its column through sql server management studio express (2008 r2) , and I add a class file to the project(in visual studio) and using linq i do mapping of that table i made in Sql studio. e.g [column] public string firstname; [column] public string lname; etc etc. My question is , if i want to make a new table and add its column etc through the windows forms application in c# at runtime (using sql commands etc) , how can i use linq to automatically map the newly created table without manually editing the code? What should i do, i have to use LINQ to SQL.. PLZ HELP

    D 1 Reply Last reply
    0
    • W wjbjnr

      Hi ! I have a very odd problem. I am using LinqtoSql in my project in c#. , and what i do is i create a new table and set its column through sql server management studio express (2008 r2) , and I add a class file to the project(in visual studio) and using linq i do mapping of that table i made in Sql studio. e.g [column] public string firstname; [column] public string lname; etc etc. My question is , if i want to make a new table and add its column etc through the windows forms application in c# at runtime (using sql commands etc) , how can i use linq to automatically map the newly created table without manually editing the code? What should i do, i have to use LINQ to SQL.. PLZ HELP

      D Offline
      D Offline
      dasblinkenlight
      wrote on last edited by
      #2

      OK, so you create your DB table at run-time. But what about the class to which you are mapping the newly created table, is it created at run-time as well? If it is (i.e. you generate and compile the code, or emit CLR byte code) you could provide [column] attributes too: there is no "LINQ-specific magic" in .NET, so you can do nearly anything the compiler can.

      W 1 Reply Last reply
      0
      • D dasblinkenlight

        OK, so you create your DB table at run-time. But what about the class to which you are mapping the newly created table, is it created at run-time as well? If it is (i.e. you generate and compile the code, or emit CLR byte code) you could provide [column] attributes too: there is no "LINQ-specific magic" in .NET, so you can do nearly anything the compiler can.

        W Offline
        W Offline
        wjbjnr
        wrote on last edited by
        #3

        Thats the problem about classes . that how can i add new class file to the project and add attributes at runtime?

        D 1 Reply Last reply
        0
        • W wjbjnr

          Thats the problem about classes . that how can i add new class file to the project and add attributes at runtime?

          D Offline
          D Offline
          dasblinkenlight
          wrote on last edited by
          #4

          You cannot add new classes to your project at run-time. You need to write a program that creates classes dynamically, for example using CodeDom[^] or Emit[^] APIs of .NET. CodeProject has examples of using both these sets of APIs[^].

          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