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 over DataSet

LINQ over DataSet

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqxmlhelp
2 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.
  • I Offline
    I Offline
    Illegal Operation
    wrote on last edited by
    #1

    I have an XML file that I need to run a LINQ query against and return some values. What I am doing is reading the XML file into a DataSet and then execute the query, the problem is that the DataSet gets two DataTables 0, 1. I need to check the CaseId and Password in Table[0] and display Notes from Table[1]. How would I query two tables using one LINQ query? My query goes something like this:

    var query = from a in ds.Tables[0].AsEnumarable()
    where a.Field("CaseId") == txtCaseId.Text && a.Field("Pwd") == txtPassword.Text
    select new
    {
    CaseID = a.Field("CaseId"),
    CaseManager = a.Field("CaseManager"),

                          //HERE IS MY PROBLEM!!
                          //HERE I NEED TO GET INFORMATION FROM TABLE\[1\] BASED ON THE CASEID IN TABLE\[0\]
                          NoteCreated = ?.Field("NoteCreated"),
                      }
    

    Illegal Operation

    J 1 Reply Last reply
    0
    • I Illegal Operation

      I have an XML file that I need to run a LINQ query against and return some values. What I am doing is reading the XML file into a DataSet and then execute the query, the problem is that the DataSet gets two DataTables 0, 1. I need to check the CaseId and Password in Table[0] and display Notes from Table[1]. How would I query two tables using one LINQ query? My query goes something like this:

      var query = from a in ds.Tables[0].AsEnumarable()
      where a.Field("CaseId") == txtCaseId.Text && a.Field("Pwd") == txtPassword.Text
      select new
      {
      CaseID = a.Field("CaseId"),
      CaseManager = a.Field("CaseManager"),

                            //HERE IS MY PROBLEM!!
                            //HERE I NEED TO GET INFORMATION FROM TABLE\[1\] BASED ON THE CASEID IN TABLE\[0\]
                            NoteCreated = ?.Field("NoteCreated"),
                        }
      

      Illegal Operation

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      How about something like this...

      var query = from a in ds.Tables[0].AsEnumarable()
      where a.Field("CaseId") == txtCaseId.Text && a.Field("Pwd") == txtPassword.Text && b.Field("CaseId") == txtCaseId.Text
      select new
      {
      CaseID = a.Field("CaseId"),
      CaseManager = a.Field("CaseManager"),
      NoteCreated = b.Field("NoteCreated"),
      }

      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