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. selecting data from view using datacontext

selecting data from view using datacontext

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqhelptutorial
10 Posts 4 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.
  • H Offline
    H Offline
    haseeb_saeed
    wrote on last edited by
    #1

    Hi, I am trying to retrieve data from a view (created as innerjoin from two tables) using linq. i have created a dbml (linq to sql file) and have added all my tables. i don't know how to add view and have no idea how i would retrieve information from a view using linq. Please provide help in this regard thanx, best regards

    haseeb

    R V 2 Replies Last reply
    0
    • H haseeb_saeed

      Hi, I am trying to retrieve data from a view (created as innerjoin from two tables) using linq. i have created a dbml (linq to sql file) and have added all my tables. i don't know how to add view and have no idea how i would retrieve information from a view using linq. Please provide help in this regard thanx, best regards

      haseeb

      R Offline
      R Offline
      Rolando CC
      wrote on last edited by
      #2

      Hi, You can add a view like a normal table, and Query it in the same way: I added a view called View1, so visual studio creates me a class for it and do this: Dim query = From v In BD.View1s _ Select v.desc, v.day And it works... :)

      H 2 Replies Last reply
      0
      • R Rolando CC

        Hi, You can add a view like a normal table, and Query it in the same way: I added a view called View1, so visual studio creates me a class for it and do this: Dim query = From v In BD.View1s _ Select v.desc, v.day And it works... :)

        H Offline
        H Offline
        haseeb_saeed
        wrote on last edited by
        #3

        I tried it but it is not working like that , is there any problem with refreshing the dbml file coz i made that some time ago...

        haseeb

        1 Reply Last reply
        0
        • R Rolando CC

          Hi, You can add a view like a normal table, and Query it in the same way: I added a view called View1, so visual studio creates me a class for it and do this: Dim query = From v In BD.View1s _ Select v.desc, v.day And it works... :)

          H Offline
          H Offline
          haseeb_saeed
          wrote on last edited by
          #4

          actually, another person made this dbml file ...he left the project and now i am assigned the project. I added this view coz i needed to select via inner join... now that i have made this view , i want to use it as he has used other tables.... would i have to add something manually for the view or not... how do i use this view as normal tables are used...thanx for helping

          haseeb

          R 1 Reply Last reply
          0
          • H haseeb_saeed

            actually, another person made this dbml file ...he left the project and now i am assigned the project. I added this view coz i needed to select via inner join... now that i have made this view , i want to use it as he has used other tables.... would i have to add something manually for the view or not... how do i use this view as normal tables are used...thanx for helping

            haseeb

            R Offline
            R Offline
            Rolando CC
            wrote on last edited by
            #5

            I think the only you have to do is drag and drop the view inside the DBML with the other tables. Have you tried in a new project with a new .dmbl? :suss:

            H 1 Reply Last reply
            0
            • H haseeb_saeed

              Hi, I am trying to retrieve data from a view (created as innerjoin from two tables) using linq. i have created a dbml (linq to sql file) and have added all my tables. i don't know how to add view and have no idea how i would retrieve information from a view using linq. Please provide help in this regard thanx, best regards

              haseeb

              V Offline
              V Offline
              vishalg_gupta
              wrote on last edited by
              #6

              Hi haseeb, you can use the keyword join for inner join. For details check out at http://openreferals.com/blogs/post/How-to-use-LINQ.aspx[^]

              H M 2 Replies Last reply
              0
              • V vishalg_gupta

                Hi haseeb, you can use the keyword join for inner join. For details check out at http://openreferals.com/blogs/post/How-to-use-LINQ.aspx[^]

                H Offline
                H Offline
                haseeb_saeed
                wrote on last edited by
                #7

                thanx it worked

                haseeb

                V 1 Reply Last reply
                0
                • R Rolando CC

                  I think the only you have to do is drag and drop the view inside the DBML with the other tables. Have you tried in a new project with a new .dmbl? :suss:

                  H Offline
                  H Offline
                  haseeb_saeed
                  wrote on last edited by
                  #8

                  it worked. thanx

                  haseeb

                  1 Reply Last reply
                  0
                  • H haseeb_saeed

                    thanx it worked

                    haseeb

                    V Offline
                    V Offline
                    vishalg_gupta
                    wrote on last edited by
                    #9

                    ur welcome.

                    1 Reply Last reply
                    0
                    • V vishalg_gupta

                      Hi haseeb, you can use the keyword join for inner join. For details check out at http://openreferals.com/blogs/post/How-to-use-LINQ.aspx[^]

                      M Offline
                      M Offline
                      mhasan0
                      wrote on last edited by
                      #10

                      hi mohamad

                      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