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. Send data from code behind

Send data from code behind

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqtutorial
6 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.
  • M Offline
    M Offline
    M K BASHER
    wrote on last edited by
    #1

    How to send data to database through linq from code behind tahnks

    N L 2 Replies Last reply
    0
    • M M K BASHER

      How to send data to database through linq from code behind tahnks

      N Offline
      N Offline
      Niladri_Biswas
      wrote on last edited by
      #2

      What does it mean? Is the question clear to you?

      Niladri Biswas

      1 Reply Last reply
      0
      • M M K BASHER

        How to send data to database through linq from code behind tahnks

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        There is no special method for doing this. However, you might want to consider your architecture. I don't think puting LINQ queries into the code behind isgood OOP. I have allways placed the LINQ stuff in the DataContext helper classes. This allwos you to reuse the code more efficently. However, if you are not doing LINQ to SQL, you may find some instances where you might want to directly use LINQ to XML in the code behind, although I can't think of any.

        M 1 Reply Last reply
        0
        • L Lost User

          There is no special method for doing this. However, you might want to consider your architecture. I don't think puting LINQ queries into the code behind isgood OOP. I have allways placed the LINQ stuff in the DataContext helper classes. This allwos you to reuse the code more efficently. However, if you are not doing LINQ to SQL, you may find some instances where you might want to directly use LINQ to XML in the code behind, although I can't think of any.

          M Offline
          M Offline
          M K BASHER
          wrote on last edited by
          #4

          Thanks Actually I was trying to insert data using Listview where Linq is used as a data source. But there is a datetime field to be inserted thats need to convert from string to datetime. for this i need to send data from code behind as we usually do when use objectdatasource like.. e.InputParameters["Parameter"] = value;

          L 1 Reply Last reply
          0
          • M M K BASHER

            Thanks Actually I was trying to insert data using Listview where Linq is used as a data source. But there is a datetime field to be inserted thats need to convert from string to datetime. for this i need to send data from code behind as we usually do when use objectdatasource like.. e.InputParameters["Parameter"] = value;

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Okay I understand now. The way I have extended functionality of the ORM is to create a partial class extension. This will save you headaches in the future. If you place all your code in the auto generated classes from SQLMetal or the Visual Studio ORM, the generator will write over your changes. There are a couple of methods for accomplishing what you would like to do. If the SQL db artifact is a string then you will need to convert the string to a DateTime Object, or use a RegEx to parse the string into the desired output. Is the SQL db artiface is a DateTime SQL column, then the ORM will create an association to the LINQ model as a DateTime Field/Property. No conversion necessary, However you may need to format the DateTime object to match your achitecural specifications. Additionally, there is an event model which is created if you used SQLMetal or the Studio ORM mapper to generate your stub. You can also overload these events in your partial class. CURD drives most of the events, with the exception of a few that are driven pre and post CRUD operations. Ie. LINQ2SQL driven. You could even use a combination of DateTime and String objects to map to your ORM in the partial classes, provied you follow the DataContext constructs and event handeling for custom attributes. Some resources: DateTime Conversion and Formating Thread[^]

            M 1 Reply Last reply
            0
            • L Lost User

              Okay I understand now. The way I have extended functionality of the ORM is to create a partial class extension. This will save you headaches in the future. If you place all your code in the auto generated classes from SQLMetal or the Visual Studio ORM, the generator will write over your changes. There are a couple of methods for accomplishing what you would like to do. If the SQL db artifact is a string then you will need to convert the string to a DateTime Object, or use a RegEx to parse the string into the desired output. Is the SQL db artiface is a DateTime SQL column, then the ORM will create an association to the LINQ model as a DateTime Field/Property. No conversion necessary, However you may need to format the DateTime object to match your achitecural specifications. Additionally, there is an event model which is created if you used SQLMetal or the Studio ORM mapper to generate your stub. You can also overload these events in your partial class. CURD drives most of the events, with the exception of a few that are driven pre and post CRUD operations. Ie. LINQ2SQL driven. You could even use a combination of DateTime and String objects to map to your ORM in the partial classes, provied you follow the DataContext constructs and event handeling for custom attributes. Some resources: DateTime Conversion and Formating Thread[^]

              M Offline
              M Offline
              M K BASHER
              wrote on last edited by
              #6

              Thanks a lot

              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