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. Returning a LINQ query

Returning a LINQ query

Scheduled Pinned Locked Moved LINQ
databasequestioncsharplinqdesign
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.
  • 1 Offline
    1 Offline
    1 21 Gigawatts
    wrote on last edited by
    #1

    Hi peeps, This is probably a easy question for someone to answer. What I've done is to encapsulate all my LINQ queries in a class, and then the UI calls that classes methods to obtain data. So In the DataContextClass I have got a method that returns the result of a query, but what do I make the return type of the method itslef??? Notice that the query returns 2 classes - the QuickLink class, and User class. public ??????????? GetSingleLink(){ . . . return( (from lnk in db.QuickLinks where lnk.LinkID == checkDataLink.LinkID select new { LinkID = lnk.LinkID, Url = lnk.Url, CreatedByUser = lnk.CreatedByUser, User = from u in db.Users select new{ UserID = lnk.CreatedByUser, Email = u.Email }, CreatedDate = lnk.CreatedDate, }) ); } This is driving me nuts :wtf: :omg:

    A 1 Reply Last reply
    0
    • 1 1 21 Gigawatts

      Hi peeps, This is probably a easy question for someone to answer. What I've done is to encapsulate all my LINQ queries in a class, and then the UI calls that classes methods to obtain data. So In the DataContextClass I have got a method that returns the result of a query, but what do I make the return type of the method itslef??? Notice that the query returns 2 classes - the QuickLink class, and User class. public ??????????? GetSingleLink(){ . . . return( (from lnk in db.QuickLinks where lnk.LinkID == checkDataLink.LinkID select new { LinkID = lnk.LinkID, Url = lnk.Url, CreatedByUser = lnk.CreatedByUser, User = from u in db.Users select new{ UserID = lnk.CreatedByUser, Email = u.Email }, CreatedDate = lnk.CreatedDate, }) ); } This is driving me nuts :wtf: :omg:

      A Offline
      A Offline
      Al Beback
      wrote on last edited by
      #2

      public IQueryable<QuickLink> GetSingleLink(){ . . . return( (from lnk in db.QuickLinks where lnk.LinkID == checkDataLink.LinkID select new QuickLink() { LinkID = lnk.LinkID, Url = lnk.Url, CreatedByUser = lnk.CreatedByUser, User = from u in db.Users select new User() { UserID = lnk.CreatedByUser, Email = u.Email }, CreatedDate = lnk.CreatedDate, }) ); } Cheers! Al

      - Is God willing to prevent evil, but not able? Then he is impotent. - Is he able, but not willing? Then he is malevolent. - Is he both able and willing? Whence then is evil? - Is he neither able nor willing? Then why call him God? Epicurus

      1 1 Reply Last reply
      0
      • A Al Beback

        public IQueryable<QuickLink> GetSingleLink(){ . . . return( (from lnk in db.QuickLinks where lnk.LinkID == checkDataLink.LinkID select new QuickLink() { LinkID = lnk.LinkID, Url = lnk.Url, CreatedByUser = lnk.CreatedByUser, User = from u in db.Users select new User() { UserID = lnk.CreatedByUser, Email = u.Email }, CreatedDate = lnk.CreatedDate, }) ); } Cheers! Al

        - Is God willing to prevent evil, but not able? Then he is impotent. - Is he able, but not willing? Then he is malevolent. - Is he both able and willing? Whence then is evil? - Is he neither able nor willing? Then why call him God? Epicurus

        1 Offline
        1 Offline
        1 21 Gigawatts
        wrote on last edited by
        #3

        Thanks for taking the time to reply mate, but I've just figured it out! It was a long day, doing to many things at once, and I suffer from a rare stupidity based disease called 'Code blindness'. ;)

        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