Linq subtraction sum(values) from two tables


I have two db.Table1 and db.Table2 with columns named IdUser,Value I think I should have some join but i miss the logic

it's just a logic it's not a code how can do something like :

var total = Sum(db.Table1(Sum(Value))-db.Table2(Sum(Value)) .Where(db.Table1.IdUser=db.Table2.IdUser)


Join the tables and group

var total = from table1record in Table1 join table2record in Table2 on table1Record.IdUser equals table2Record.IdUser group new { table1record,table2record } by table1record.IdUser into groupedRecords select groupedRecords.Sum(x=>x.Table1Value) - groupedRecords.Sum(x=>x.Table2Value);


  • onchange jquery validation for file type
  • ODBC: How to bind a empty string?
  • use stream to sum all values from array stored in map
  • getting the output of external program to c++ code [duplicate]
  • Set Date Range in gapi class for analytics
  • How can I use 'addChildEventListener()' accurately for following purpose?
  • sql1 to get names and sql2 to get Impressions, I need to sort names by Impressions
  • have mysql select statement return fully qualified column names like table.field
  • FluentMigrator Failed Migrations Don't Rollback?
  • Migrating row from one table to another with conditions [MYSQL]
  • Insert records into two table at once
  • MongoDB GeoJSON “Can't extract geo keys from object, malformed geometry?” when inserting type P
  • It is possible use the same sql azure instance from two different cloud service of two different sub
  • Count from each distinct date, fill in missing dates with zero
  • MVC - @Html.CheckBoxFor
  • Get used tables from sql query [duplicate]
  • pymongo replication secondary readreference not work
  • SQL: Getting the physical size of a subset of a table
  • sweetalert2 inputoptions from file in select example
  • Open Existing DB in MySQL WorkBench
  • pip in virtualenv gets ConnectTimeoutError
  • RxJava debounce by arbitrary value
  • Run multiple queries from 1 SQL file showing result in multiple tables
  • How can I extract results of aggregate queries in slick?
  • Marklogic : Query response time is very high
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • onBackPressed() not being executed
  • Django: Count of Group Elements
  • MongoDB in PHP using aggregate to group by _id is null not working
  • How to check if every primary key value is being referenced as foreign key in another table
  • How to handle AllServersUnavailable Exception
  • ActionScript 2 vs ActionScript 3 performance
  • How to get next/previous record number?
  • File upload with ng-file-upload throwing error
  • How to delete a row from a dynamic generate table using jquery?
  • using HTMLImports.whenReady not working in chrome
  • Why joiner is not used after Sequence generator or Update statergy
  • Turn off referential integrity in Derby? is it possible?
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection