score:1
i've taken the liberty of beatifying your tsql a little.
the last two join conditions appear malformed to me so this tsql can not be parsed.
select
[t].sanadid
, [t].date
, [a].id [accid]
, [a].fullid
, [a].name
, sum([t].debit) [totaldebit]
, sum([t].credit) [totalcredit]
from
dbo.finnaccount [a1]
left outer join
dbo.finnaccount [a]
on [a1].parentid = [a].id
right outer join
dbo.finntrans [t]
left outer join
dbo.finnaccount [a2]
on [a].accid = [a2].id
on [a1].id = [a2].parentid
where
[t].fpid = 7
and
[a2].acclevel = 3
group by
[t].sanadid
, [t].date
, [a].id
, [a].name
, [a].fullid
having
[t].sanadid = 1
score:2
you can look here: http://www.hookedonlinq.com/outerjoinsample.ashx as an example of the left outer join. and you can always swap tables to get either left or right
Source: stackoverflow.com
Related Query
- How to make a right join using LINQ to SQL & C#?
- Linq to sql - Join 2 tables, select 1 row from right table with a 1 to many relationship
- SQL to Linq: RIGHT JOIN in LINQ
- LINQ to SQL Right Outer Join
- Select latest 'N' records on the right table for each record on left table of left join on linq to sql
- Linq to SQL - Right Join
- Convert SQL to Linq for left join with NULL in right
- SQL to LINQ - multiple tables left outer join with where clause referring right table
- Convert sql code to linq (Inner join Query)
- C# LINQ translation for a SQL query with RIGHT JOIN
- LINQ to SQL - Left Outer Join with multiple join conditions
- LINQ to SQL Left Outer Join
- Convert SQL to Linq left join with null
- LINQ to SQL multiple tables left outer join
- How are people unit testing code that uses Linq to SQL
- linq to sql join on multiple columns using lambda
- How do I most elegantly express left join with aggregate SQL as LINQ query
- Left join on two Lists and maintain one property from the right with Linq
- Use contains in LINQ to SQL join
- SQL Query to LINQ syntax using not exist and join
- LINQ to SQL join generates SQL which joins on IS NULL
- LINQ to SQL Join issues
- Left outer join using LINQ -- understanding the code
- linq to sql left join, need to check for null for right table
- LINQ Source Code Available
- What's the difference between left side and right side of the equals in a LINQ join
- LINQ to SQL and Join two tables with OR clause
- EF Linq to Entities calling ToList() on entity set generates SQL command containing multiple left outer join
- SQL to LINQ with multiple join, count and left join
- LINQ to SQL Join issues with FirstOrDefault()
More Query from same tag
- LINQ - ConflictChangeException
- Has Microsoft Fixed Linq to Entities Performance Problems in .NET 4.0?
- Linq PredicateBuilder multi criteria
- Unable to cast object of type 'System.Data.Linq.DataQuery`1[System.Int32]' to type 'System.IConvertible'
- Create Hierarchy in LINQ
- Get Results from Linq query(System.Data.Entity.Infrastructure.DbQuery) and convert to List
- Read the XML using Linq and check if the elements exist
- Linq to XML: I am not able to compare the nested element
- Compiled LINQ joins
- Convert lambda expression to Json
- LINQ 'join' expects an equals but I would like to use 'contains'
- Linq Grouping - aggregate, outside of a group by
- Incorrect joining of tables in linq
- Linq produce a list of missing records for a given date range
- How to Convert Lambda Expression To Sql?
- LINQ Union with duplicates
- How to insert data into a field using C # parallel programming
- Creating KML with Linq to XML
- How to Insert a New Node Using LINQ to XML when only xml data is available?
- How to pass an external parameter to LINQ where clause in CRM
- Linq: Selecting current month Data but checking if anything needs carrying over from previous months
- How can I set the value of a parameter inside of an object?
- Copy subset of items from one RadComboBox to another
- Taking a single record from array returned by result
- Inner join to LINQ
- How to convert List<object> to List<CustomClass>?
- c# Lambda query in list that has a list inside for mapping
- Question about length of an object in LINQ
- LINQ: Sort by (Treat letters as numbers)
- Fail to iterate through collection returned