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 oddity...

LINQ oddity...

Scheduled Pinned Locked Moved LINQ
csharpdatabasewpfwcflinq
3 Posts 2 Posters 3 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.
  • U Offline
    U Offline
    User 4122428
    wrote on last edited by
    #1

    Hi All,   I'm new to Linq. I've got the following code to take two tables, and result in the rows from table1 that are NOT in table2.   The Linq is out of the book <u>Pro Linq</u> from Apress.                   Dim seq1 As IEnumerable(Of DataRow) = table1.AsEnumerable()                   Dim seq2 As IEnumerable(Of DataRow) = table2.AsEnumerable()                   Dim except As IEnumerable(Of DataRow) = seq1.Except(seq2, System.Data.DataRowComparer.Default)                   Dim Table3 As New DataTable                   Dim NewTableColumn As DataColumn = Table3.Columns.Add("UserName")                                  'For Each row resulting from LINQ query, add to new table.                   For Each dr As DataRow In except                         Dim NewRow1 As DataRow = Table3.NewRow()                         NewRow1("UserName") = dr.Item(0).ToString                         Table3.Rows.Add(NewRow1)                   Next Obviously I don't understand something about Linq.   When the page runs through the procedure for the first time, everything works.   The variable "except" contains the correct rows.   However, after binding and postback, though I've confirmed that Table1 and Table2 contain the correct rows, the linq doesn't respond as expected.   It's as if it is doing nothing at all.   Any thoughts on this?   Thanks in advance!

    A 1 Reply Last reply
    0
    • U User 4122428

      Hi All,   I'm new to Linq. I've got the following code to take two tables, and result in the rows from table1 that are NOT in table2.   The Linq is out of the book <u>Pro Linq</u> from Apress.                   Dim seq1 As IEnumerable(Of DataRow) = table1.AsEnumerable()                   Dim seq2 As IEnumerable(Of DataRow) = table2.AsEnumerable()                   Dim except As IEnumerable(Of DataRow) = seq1.Except(seq2, System.Data.DataRowComparer.Default)                   Dim Table3 As New DataTable                   Dim NewTableColumn As DataColumn = Table3.Columns.Add("UserName")                                  'For Each row resulting from LINQ query, add to new table.                   For Each dr As DataRow In except                         Dim NewRow1 As DataRow = Table3.NewRow()                         NewRow1("UserName") = dr.Item(0).ToString                         Table3.Rows.Add(NewRow1)                   Next Obviously I don't understand something about Linq.   When the page runs through the procedure for the first time, everything works.   The variable "except" contains the correct rows.   However, after binding and postback, though I've confirmed that Table1 and Table2 contain the correct rows, the linq doesn't respond as expected.   It's as if it is doing nothing at all.   Any thoughts on this?   Thanks in advance!

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Member 4125480 wrote:

      It's as if it is doing nothing at all.

      This is weird.. There must be some problem with Datatables. Otherwise how it is possible.. :wtf:

      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


      My Latest Articles-->** Microsoft Bing MAP using Javascript
      CLR objects in SQL Server 2005
      Uncommon C# Keywords
      /xml>

      U 1 Reply Last reply
      0
      • A Abhishek Sur

        Member 4125480 wrote:

        It's as if it is doing nothing at all.

        This is weird.. There must be some problem with Datatables. Otherwise how it is possible.. :wtf:

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Microsoft Bing MAP using Javascript
        CLR objects in SQL Server 2005
        Uncommon C# Keywords
        /xml>

        U Offline
        U Offline
        User 4122428
        wrote on last edited by
        #3

        You were right.   I had made a booboo previously in my datatables.   It works now.   :)

        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