Click here to Skip to main content
12,621,744 members (37,811 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# LINQ
Hello
I cant convert this Query in SQL Server to LINQ

SELECT dbo.ReportType.Name
FROM   dbo.Center INNER JOIN
       dbo.SwitchType ON dbo.Center.ID = dbo.SwitchType.ID FULL JOIN
       dbo.ReportType ON dbo.Center.ID = dbo.ReportType.ID

Pleas help me .
Posted 17-Nov-12 21:11pm
Updated 18-Nov-12 3:11am
Nelek110.5K
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

1.Go to sql server and create a [VIEW] and join table's together.
2.Add View to LINQ to SQL
3.
DataClasses1DataContext db = new DataClasses1DataContext();
ViewNameBindingSource.DataSource = db.ViewName.Where(c => c.Name=="KeySearch").Select(c=>c);
//ViewNameBindingSource BindingSource For ReportView 


2)Example By linq
//linq to entities three table join query
var query = from p in db.QuizParticipants
            join points in db.ParticipantPoints on p.id 
            equals points.participantId into participantsGroup
            from po in participantsGroup
            join winners in db.Winners on p.id 
            equals winners.participantId into winnersGroup
            from w in winnersGroup
            where p.hasAttended == 1 && p.weeknumber == weeknumber
            select new
            {
                ParticipantId = p.id,
                HasAttended = p.hasAttended,
                Weeknumber = p.weeknumber, 
                UmbracoMemberId = p.umbMemberId,
                Points = po.points,
                HasWonFirstPrize = w.hasWonFirstPrize,
                HasWonVoucher = w.hasWonVoucher                                    
            };
  Permalink  
v4
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

select * from PersonInfo
where code
in
(select a.Code from PersonInfo as a ,TradeElamieh as b
where a.Code=b.person1 and b.Actual=1 and (a.Investor_ID like'1338%' or a.Investor_ID like'1339%')
 and b.date>'2012-01-01' and a.Investor_ID IS NOT NULL)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 21 Jan 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100