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. How To Convert This To Linq

How To Convert This To Linq

Scheduled Pinned Locked Moved LINQ
csharpasp-netlinqhelptutorial
3 Posts 3 Posters 4 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.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    I'm fairly new with Linq. Could use some help.... I need to convert this to Linq:

    SELECT r1.*
    FROM aspnet_Roles r1
    WHERE r1.RoleId IN
    (SELECT r2.RoleId
    FROM mmlaspnet_RolesToGlobalRoles r2)
    ORDER BY RoleName

    help!

    Everything makes sense in someone's mind

    H F 2 Replies Last reply
    0
    • K Kevin Marois

      I'm fairly new with Linq. Could use some help.... I need to convert this to Linq:

      SELECT r1.*
      FROM aspnet_Roles r1
      WHERE r1.RoleId IN
      (SELECT r2.RoleId
      FROM mmlaspnet_RolesToGlobalRoles r2)
      ORDER BY RoleName

      help!

      Everything makes sense in someone's mind

      H Offline
      H Offline
      hermiod
      wrote on last edited by
      #2

      Assuming you have a DataContext hooked up to the db which we will call dbc, it should go something like this. dim r2=from i in dbc.mmlaspnet_RolesToGlobalRoles dim r1 = from i in dbc.aspnet_roles where i.RoleId.contains(r2) Not totally sure on the syntax of that one but that should get you started.

      "It`s always better to have a big long wick"

      1 Reply Last reply
      0
      • K Kevin Marois

        I'm fairly new with Linq. Could use some help.... I need to convert this to Linq:

        SELECT r1.*
        FROM aspnet_Roles r1
        WHERE r1.RoleId IN
        (SELECT r2.RoleId
        FROM mmlaspnet_RolesToGlobalRoles r2)
        ORDER BY RoleName

        help!

        Everything makes sense in someone's mind

        F Offline
        F Offline
        Fernando Soto
        wrote on last edited by
        #3

        Let say that the instantiated data context is db, then you query in Linq would be as follows :

        var r2 = from rtgr in db.mmlaspnet_RolesToGlobalRoles
        select rtgr.RoleId;
        var r1 = from r in db.aspnet_Roles
        where r2.Contains(r.RoleId)
        orderby r.RoleName
        select r;

        fereach( var roles in r1 )
        {
        Console.WriteLine("RoleID = {0} ....", role.RoleId, ...);
        }

        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