Note that there are some explanatory texts on larger screens.

plurals
  1. POcomplex query using LINQ and C#
    primarykey
    data
    text
    <p>I have a very big problem solving this issue I have 2 tables </p> <p>first table is : <a href="http://picasaweb.google.com/lh/photo/iDp4kgFFjk5d2h5dUZtbvg?feat=embedwebsite" rel="nofollow noreferrer">http://lh3.ggpht.com/_uMvfbnPHuko/SYPJQ1ZsBDI/AAAAAAAAAKs/eq49xquy3jM/s800/Untitled-2.jpg</a></p> <p>which contains a modules (id and name)</p> <p>second table is <a href="http://picasaweb.google.com/lh/photo/PsT4H6bZ0lH8rN7ZPRMbjQ?feat=embedwebsite" rel="nofollow noreferrer">http://lh6.ggpht.com/_uMvfbnPHuko/SYPJQ4IXGwI/AAAAAAAAAK0/zmTIO6V-UEQ/s800/Untitled-3.jpg</a></p> <p>which contains users ids and their preferred modules' numbers</p> <p>now lets move to the problem I want to generate a list of checkboxes</p> <p>for example for the userid 1 which has the following modules "3,2 and 4" the result will be</p> <p><a href="http://picasaweb.google.com/lh/photo/KSQIDk_jeuIfyFabCsgXow?feat=embedwebsite" rel="nofollow noreferrer">http://lh4.ggpht.com/_uMvfbnPHuko/SYPJQ_LJeVI/AAAAAAAAAK8/6RV8a1S8eCY/s800/Untitled-4.jpg</a></p> <p>notice that "recommended for you" checkbox is not checked because the user 1 does not have module id "1"</p> <p>I spent a long time trying to solve this problem using c# and LINQ</p> <p>see the result of my effort :) (the following code does not work)</p> <pre><code> var q = from m in db.modules from um in db.usersModules.Where(um2 =&gt; um2.userId == myUserId).Single().modules.Trim().Split(',') where um.Contains(m.moduleId.ToString()) select new { moduleid = here i want the module id from modules table modulename = here i want the modulename from modules table ischecked = here i want "true" or "false" depending on if the user has this module or not }; </code></pre> <p>If LINQ is easy for you please try to solve this one? any questions?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload