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 Select Distinct with aggregate columns in Entity Framework with LINQ?

How to Select Distinct with aggregate columns in Entity Framework with LINQ?

Scheduled Pinned Locked Moved LINQ
questioncsharpdatabaselinqtutorial
2 Posts 2 Posters 15 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.
  • M Offline
    M Offline
    me dagsunde com
    wrote on last edited by
    #1

    Say I have a userTable and an orderTable. the criteria for the usertable is such that I WILL get the same user more than once How do I do a DISTINCT and a SUM(...) in Linq? In SQL it is : SELECT DISTINCT u.Name, u.Phone, SUM(o.Amount) FROM User u JOIN Order o ON u.UserId = o.UserId WHERE u.Type = 1 OR u.External = 1 GROUP BY Name, Phone TIA... -- Dag

    A 1 Reply Last reply
    0
    • M me dagsunde com

      Say I have a userTable and an orderTable. the criteria for the usertable is such that I WILL get the same user more than once How do I do a DISTINCT and a SUM(...) in Linq? In SQL it is : SELECT DISTINCT u.Name, u.Phone, SUM(o.Amount) FROM User u JOIN Order o ON u.UserId = o.UserId WHERE u.Type = 1 OR u.External = 1 GROUP BY Name, Phone TIA... -- Dag

      A Offline
      A Offline
      Anurag Gandhi
      wrote on last edited by
      #2

      Use SQL To Linq of LinqPad to convert your sql queries to Linq. Below are the link: Linqer | SQL to LINQ converter[^] LINQPad - The .NET Programmer's Playground[^]

      Life is a computer program and everyone is the programmer of his own life.

      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