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. join query with group and condition

join query with group and condition

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinq
3 Posts 3 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.
  • F Offline
    F Offline
    fawaddd
    wrote on last edited by
    #1

    I want to execute following sql using linq in c# select sum(EDAmount) from accounts a inner join entriesdetail ed on a.Acode =ed.acode inner join entries e on ed.eid = e.eid and e.edate > '1/1/2009' group by ed.acode Following are the entities Accounts - ACode Entry - EID - EDate EntryDetail - EDID - EID - EDAmound - ACode

    I N 2 Replies Last reply
    0
    • F fawaddd

      I want to execute following sql using linq in c# select sum(EDAmount) from accounts a inner join entriesdetail ed on a.Acode =ed.acode inner join entries e on ed.eid = e.eid and e.edate > '1/1/2009' group by ed.acode Following are the entities Accounts - ACode Entry - EID - EDate EntryDetail - EDID - EID - EDAmound - ACode

      I Offline
      I Offline
      Ian McCaul
      wrote on last edited by
      #2

      Try this.

      var sumEDA =
      from a in context.accounts
      join ed in context.entriesdetail on a.Acode equals ed.acode
      join e in context.entries on ed.eid equals e.eid
      where e.edate > Convert.ToDateTime("1/1/2009")
      group g by ed.acode
      select new { g.Sum(ed.EDAmount) };

      1 Reply Last reply
      0
      • F fawaddd

        I want to execute following sql using linq in c# select sum(EDAmount) from accounts a inner join entriesdetail ed on a.Acode =ed.acode inner join entries e on ed.eid = e.eid and e.edate > '1/1/2009' group by ed.acode Following are the entities Accounts - ACode Entry - EID - EDate EntryDetail - EDID - EID - EDAmound - ACode

        N Offline
        N Offline
        Niladri_Biswas
        wrote on last edited by
        #3

        from a in Accounts join ed in EntryDetail on a.ACODE equals ed.ACODE join e in Entry on e.EID equals ed.EID where e.EDATE > DateTime.Parse("1/1/1990") group ed by ed.ACODE into g select new { g.Group.Sum(s => s.EDAMOUNT) }; Please vote me :)

        Niladri Biswas

        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