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. .NET (Core and Framework)
  4. Get list from list of elements link and collections

Get list from list of elements link and collections

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestioncsharplinq
3 Posts 2 Posters 0 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.
  • S Offline
    S Offline
    simpledeveloper
    wrote on last edited by
    #1

    Hi, I have 3 tables in the back end - I am trying to load them using include statement of Entity Framework TableA is parent of TableB which is parent of TableC (from a in TableA select a).Include("TableB").Include("TableB.TableC") Now I want to get List using a Linq, how can I do it? I am trying in the below way - its giving me compile error - any help please? Thanks in advance.

    List cs = (from a in tablea.TableBs select a.TableCs.ToList());

    Any help in achieving this, that how can I get the List of TableCs in one list using linq queries

    Richard DeemingR 1 Reply Last reply
    0
    • S simpledeveloper

      Hi, I have 3 tables in the back end - I am trying to load them using include statement of Entity Framework TableA is parent of TableB which is parent of TableC (from a in TableA select a).Include("TableB").Include("TableB.TableC") Now I want to get List using a Linq, how can I do it? I am trying in the below way - its giving me compile error - any help please? Thanks in advance.

      List cs = (from a in tablea.TableBs select a.TableCs.ToList());

      Any help in achieving this, that how can I get the List of TableCs in one list using linq queries

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      If you want a list of TableCs, then start with the TableCs. Use the navigation properties to include the parent and grandparent entities if required.

      List<TableC> cs = tablea.TablesCs.Include(c => c.TableB.TableA).ToList();


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      S 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        If you want a list of TableCs, then start with the TableCs. Use the navigation properties to include the parent and grandparent entities if required.

        List<TableC> cs = tablea.TablesCs.Include(c => c.TableB.TableA).ToList();


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        S Offline
        S Offline
        simpledeveloper
        wrote on last edited by
        #3

        Yes I did that - thank you for your suggestion :)

        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