Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 833689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:33:25+00:00 2026-05-15T04:33:25+00:00

I want to replicate this query in LINQ to SQL but am too unfamiliar

  • 0

I want to replicate this query in LINQ to SQL but am too unfamiliar with how to do it.

SELECT A.Recruiter, SUM(O.SaleAmount * I.Commission)  --This sum from fields in two different tables is what I don't know how to replicate
FROM Orders AS O
INNER JOIN Affiliate A ON O.AffiliateID = A.AffiliateID
INNER JOIN Items AS I ON O.ItemID = I.ItemID
GROUP BY A.Recruiter

I’ve got this far:

from order in ctx.Orders
join item in ctx.Items on order.ItemI == item.ItemID
join affiliate in ctx.Affiliates on order.AffiliateID == affiliate.AffiliateID
group order  //can I only group one table here?
  by affiliate.Recruiter into mygroup
select new { Recruiter = mygroup.Key, Commission = mygroup.Sum(record => record.SaleAmount * ?????) };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:33:26+00:00Added an answer on May 15, 2026 at 4:33 am
    group new {order, item} by affiliate.Recruiter into mygroup 
    select new {
      Recruiter = mygroup.Key,
      Commission = mygroup
        .Sum(x => x.order.SaleAmount * x.item.Commission)
    }; 
    

    And an alternative way of writing the query:

    from aff in ctx.Affiliates
    where aff.orders.Any(order => order.Items.Any())
    select new {
      Recruiter = aff.Recruiter,
      Commission = (
        from order in aff.orders
        from item in order.Items
        select item.Commission * order.SaleAmount
        ).Sum()
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We want to replicate data from one database to several others (on another server).
I have a select from (nothing to complex) Select * from VIEW This view
I want to be able to replicate this adsutil.vbs behaviour in PowerShell: cscript adsutil.vbs
I have succesfully created a view hierarchy programmatically. I now want to replicate this
I want to replicate some functionality from Digg.com whereby when you post a new
I wonder if someone can help me. I want to replicate the following SQL
I basically want to replicate this on the blackberry - http://img641.imageshack.us/img641/4628/tempi.jpg Is there a
I've done web scraping before but it was never this complex. I want to
I want to replicate some of data that exists in my database. I want
I want to relocate some controls from one part in the visual tree to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.