join using dot notation and not exists RRS feed

  • Question

  • So I have 2 database tables. One with all the selectable items. And then another table with the selected items for each item.

    I've got 2 listboxes. One that displays the selectable items and then on the right are the already selected items. As items are selected they are removed from the selectable listbox.

    I know I could just populate the listbox with something like this


    This works fine. What I want to do is a join to the Already Selected items table. Something like this is SQL

    SELECT s.ItemName
    FROM Items s
    WHERE NOT EXISTS (SELECT 1 FROM SelectedItems si
    where si.ItemID = s.ItemID)

    Currently I'm doing the following which works
      var skills = (from s in ddDL.skills()
                    where !(from cs in ddDL.CreatureSkills(_currentID)
                            select cs.SkillID).Contains(s.SkillID)
                      select s);

    But I prefer to do it as one state using dot notation.

    Next, the selectedItems. It's in a listview. It should have 2 columns, the name and a value
    I do the following which populates the first column with the name, but how do I get my subitems
    IEnumerable<ListViewItem> myResultList = ddDL.skills().Join(ddDL.CreatureSkills(_currentID), s => s.SkillID, cs => cs.SkillID, (s, cs) => new { Name = s.Skill1, Amount = cs.Skill_Amount })
        .Select(scs => new ListViewItem() { Text = scs.Name });


    Any help is appreciated


    Joe Pacelli
    Friday, July 16, 2010 10:03 PM


All replies